[llvm-branch-commits] [cfe-branch] r118571 - in /cfe/branches/Apple/whitney: lib/Sema/SemaExpr.cpp test/SemaCXX/compound-literal.cpp

Daniel Dunbar daniel at zuster.org
Tue Nov 9 09:32:30 PST 2010


Author: ddunbar
Date: Tue Nov  9 11:32:29 2010
New Revision: 118571

URL: http://llvm.org/viewvc/llvm-project?rev=118571&view=rev
Log:
Merge r118428:
--
Author: Argyrios Kyrtzidis <akyrtzi at gmail.com>
Date:   Mon Nov 8 19:14:19 2010 +0000

    When building a compound literal, check that the base element of the array is complete.
    Fixes rdar://8620582 & http://llvm.org/PR7905

Added:
    cfe/branches/Apple/whitney/test/SemaCXX/compound-literal.cpp
Modified:
    cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp

Modified: cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp?rev=118571&r1=118570&r2=118571&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp Tue Nov  9 11:32:29 2010
@@ -3943,6 +3943,11 @@
   QualType literalType = TInfo->getType();
 
   if (literalType->isArrayType()) {
+    if (RequireCompleteType(LParenLoc, Context.getBaseElementType(literalType),
+             PDiag(diag::err_illegal_decl_array_incomplete_type)
+               << SourceRange(LParenLoc,
+                              literalExpr->getSourceRange().getEnd())))
+      return ExprError();
     if (literalType->isVariableArrayType())
       return ExprError(Diag(LParenLoc, diag::err_variable_object_no_init)
         << SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd()));

Added: cfe/branches/Apple/whitney/test/SemaCXX/compound-literal.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/SemaCXX/compound-literal.cpp?rev=118571&view=auto
==============================================================================
--- cfe/branches/Apple/whitney/test/SemaCXX/compound-literal.cpp (added)
+++ cfe/branches/Apple/whitney/test/SemaCXX/compound-literal.cpp Tue Nov  9 11:32:29 2010
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// http://llvm.org/PR7905
+namespace PR7905 {
+struct S; // expected-note {{forward declaration}}
+void foo1() {
+  (void)(S[]) {{3}}; // expected-error {{array has incomplete element type}}
+}
+
+template <typename T> struct M { T m; };
+void foo2() {
+  (void)(M<short> []) {{3}};
+}
+}





More information about the llvm-branch-commits mailing list