[cfe-commits] r44602 - in /cfe/trunk: AST/Expr.cpp Sema/SemaDecl.cpp test/Sema/compound-literal.c

Steve Naroff snaroff at apple.com
Tue Dec 4 20:00:11 PST 2007


Author: snaroff
Date: Tue Dec  4 22:00:10 2007
New Revision: 44602

URL: http://llvm.org/viewvc/llvm-project?rev=44602&view=rev
Log:

Recognize CompoundLiteralExpr's as valid lvalue's.

Also updated a FIXME in Sema::CheckInitializer()...


Added:
    cfe/trunk/test/Sema/compound-literal.c
Modified:
    cfe/trunk/AST/Expr.cpp
    cfe/trunk/Sema/SemaDecl.cpp

Modified: cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Expr.cpp?rev=44602&r1=44601&r2=44602&view=diff

==============================================================================
--- cfe/trunk/AST/Expr.cpp (original)
+++ cfe/trunk/AST/Expr.cpp Tue Dec  4 22:00:10 2007
@@ -334,6 +334,8 @@
     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;

Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=44602&r1=44601&r2=44602&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Tue Dec  4 22:00:10 2007
@@ -553,7 +553,8 @@
                           hadError);
     return hadError;
   }
-  // FIXME: Handle struct/union types.
+  // FIXME: Handle struct/union types, including those appearing in a 
+  // CompoundLiteralExpr...
   return hadError;
 }
 

Added: cfe/trunk/test/Sema/compound-literal.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/compound-literal.c?rev=44602&view=auto

==============================================================================
--- cfe/trunk/test/Sema/compound-literal.c (added)
+++ cfe/trunk/test/Sema/compound-literal.c Tue Dec  4 22:00:10 2007
@@ -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 });
+}
+





More information about the cfe-commits mailing list