From e6386394677ed4f77b20e2e3d5446a3a2f628e53 Mon Sep 17 00:00:00 2001 From: Steve Naroff Date: Wed, 5 Dec 2007 04:00:10 +0000 Subject: [PATCH] Recognize CompoundLiteralExpr's as valid lvalue's. 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 | 2 ++ Sema/SemaDecl.cpp | 3 ++- test/Sema/compound-literal.c | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/Sema/compound-literal.c diff --git a/AST/Expr.cpp b/AST/Expr.cpp index 76b2d853f4..545ebd8e18 100644 --- a/AST/Expr.cpp +++ b/AST/Expr.cpp @@ -334,6 +334,8 @@ Expr::isLvalueResult Expr::isLvalue() const { break; case ParenExprClass: // C99 6.5.1p5 return cast(this)->getSubExpr()->isLvalue(); + case CompoundLiteralExprClass: // C99 6.5.2.5p5 + return LV_Valid; case OCUVectorElementExprClass: if (cast(this)->containsDuplicateElements()) return LV_DuplicateVectorComponents; diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index e2b1fdf134..f1eb753523 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -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 index 0000000000..f57159ac6a --- /dev/null +++ b/test/Sema/compound-literal.c @@ -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 }); +} + -- 2.40.0