[cfe-commits] r159905 - in /cfe/trunk: lib/Sema/SemaType.cpp test/SemaCXX/array-bound-merge.cpp

Richard Smith richard-llvm at metafoo.co.uk
Sat Jul 7 16:00:31 PDT 2012


Author: rsmith
Date: Sat Jul  7 18:00:31 2012
New Revision: 159905

URL: http://llvm.org/viewvc/llvm-project?rev=159905&view=rev
Log:
Reject 'int a[1][];' in Sema rather than crashing in IR generation. Found by a
misreduction of PR13290.

Modified:
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/SemaCXX/array-bound-merge.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=159905&r1=159904&r2=159905&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Sat Jul  7 18:00:31 2012
@@ -1249,6 +1249,11 @@
     //   type, the (possibly cv-qualified) type void, a function type or an
     //   abstract class type.
     //
+    // C++ [dcl.array]p3:
+    //   When several "array of" specifications are adjacent, [...] only the
+    //   first of the constant expressions that specify the bounds of the arrays
+    //   may be omitted.
+    //
     // Note: function types are handled in the common path with C.
     if (T->isReferenceType()) {
       Diag(Loc, diag::err_illegal_decl_array_of_references)
@@ -1256,7 +1261,7 @@
       return QualType();
     }
 
-    if (T->isVoidType()) {
+    if (T->isVoidType() || T->isIncompleteArrayType()) {
       Diag(Loc, diag::err_illegal_decl_array_incomplete_type) << T;
       return QualType();
     }

Modified: cfe/trunk/test/SemaCXX/array-bound-merge.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/array-bound-merge.cpp?rev=159905&r1=159904&r2=159905&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/array-bound-merge.cpp (original)
+++ cfe/trunk/test/SemaCXX/array-bound-merge.cpp Sat Jul  7 18:00:31 2012
@@ -7,3 +7,5 @@
 int b[];
 extern int c[1];
 int c[] = {1,2}; // expected-error {{excess elements in array initializer}}
+
+int d[1][]; // expected-error {{array has incomplete element type 'int []'}}





More information about the cfe-commits mailing list