]> granicus.if.org Git - clang/commitdiff
Recognize CompoundLiteralExpr's as valid lvalue's.
authorSteve Naroff <snaroff@apple.com>
Wed, 5 Dec 2007 04:00:10 +0000 (04:00 +0000)
committerSteve Naroff <snaroff@apple.com>
Wed, 5 Dec 2007 04:00:10 +0000 (04:00 +0000)
Also updated a FIXME in Sema::CheckInitializer()...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44602 91177308-0d34-0410-b5e6-96231b3b80d8

AST/Expr.cpp
Sema/SemaDecl.cpp
test/Sema/compound-literal.c [new file with mode: 0644]

index 76b2d853f43280f813509f7ddf6e0f0f6e8fd270..545ebd8e182538cf25158be60c9d237ac638e8e7 100644 (file)
@@ -334,6 +334,8 @@ Expr::isLvalueResult Expr::isLvalue() const {
     break;
   case ParenExprClass: // C99 6.5.1p5
     return cast<ParenExpr>(this)->getSubExpr()->isLvalue();
+  case CompoundLiteralExprClass: // C99 6.5.2.5p5
+    return LV_Valid;
   case OCUVectorElementExprClass:
     if (cast<OCUVectorElementExpr>(this)->containsDuplicateElements())
       return LV_DuplicateVectorComponents;
index e2b1fdf134dacba5ddb23c675beea73d1c316aca..f1eb753523ada18e4872ac3f854d23bc74f7c7ad 100644 (file)
@@ -553,7 +553,8 @@ bool Sema::CheckInitializer(Expr *&Init, QualType &DeclType, bool isStatic) {
                           hadError);
     return hadError;
   }
-  // FIXME: Handle struct/union types.
+  // FIXME: Handle struct/union types, including those appearing in a 
+  // CompoundLiteralExpr...
   return hadError;
 }
 
diff --git a/test/Sema/compound-literal.c b/test/Sema/compound-literal.c
new file mode 100644 (file)
index 0000000..f57159a
--- /dev/null
@@ -0,0 +1,10 @@
+// RUN: clang -fsyntax-only -verify %s
+
+struct foo { int a, b; };
+
+extern void fooFunc(struct foo *pfoo);
+
+int main(int argc, char **argv) {
+ fooFunc(&(struct foo){ 1, 2 });
+}
+