[cfe-commits] r70178 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaType.cpp test/CodeGenObjC/encode-test.m test/SemaObjC/interface-1.m

Chris Lattner sabre at nondot.org
Sun Apr 26 18:55:56 PDT 2009


Author: lattner
Date: Sun Apr 26 20:55:56 2009
New Revision: 70178

URL: http://llvm.org/viewvc/llvm-project?rev=70178&view=rev
Log:
rdar://6827200 - [sema] reject statically allocated arrays of interface types

Upgrade "array of interface" warning to an error.  In addition to being a
terrible idea, this crashes codegen.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/CodeGenObjC/encode-test.m
    cfe/trunk/test/SemaObjC/interface-1.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=70178&r1=70177&r2=70178&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Apr 26 20:55:56 2009
@@ -1632,8 +1632,8 @@
   "C++ requires a type specifier for all declarations">;
 def err_missing_param_declspec : Error<
   "parameter requires a declaration specifier">;
-def warn_objc_array_of_interfaces : Warning<
-  "array of interface %0 should probably be an array of pointers">;
+def err_objc_array_of_interfaces : Error<
+  "array of interface %0 is invalid (probably should be an array of pointers)">;
 def ext_c99_array_usage : Extension<
   "use of C99-specific array features, accepted as an extension">;
 def err_invalid_protocol_qualifiers : Error<

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=70178&r1=70177&r2=70178&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Sun Apr 26 20:55:56 2009
@@ -487,7 +487,8 @@
     if (EltTy->getDecl()->hasFlexibleArrayMember())
       Diag(Loc, diag::ext_flexible_array_in_array) << T;
   } else if (T->isObjCInterfaceType()) {
-    Diag(Loc, diag::warn_objc_array_of_interfaces) << T;
+    Diag(Loc, diag::err_objc_array_of_interfaces) << T;
+    return QualType();
   }
       
   // C99 6.7.5.2p1: The size expression shall have integer type.

Modified: cfe/trunk/test/CodeGenObjC/encode-test.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/encode-test.m?rev=70178&r1=70177&r2=70178&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenObjC/encode-test.m (original)
+++ cfe/trunk/test/CodeGenObjC/encode-test.m Sun Apr 26 20:55:56 2009
@@ -2,7 +2,7 @@
 // RUN: grep -e "\^{Innermost=CC}" %t | count 1 &&
 // RUN: grep -e "{Derived=#ib32b8b3b8sb16b8b8b2b8ccb6}" %t | count 1 &&
 // RUN: grep -e "{B1=#@c}" %t | count 1 &&
-// RUN: grep -e "v12 at 0:4\[3\[4{Test=i}]]8" %t | count 1 &&
+// RUN: grep -e "v12 at 0:4\[3\[4@]]8" %t | count 1 &&
 // RUN: grep -e "r\^{S=i}" %t | count 1 &&
 // RUN: grep -e "\^{Object=#}" %t | count 1
 
@@ -67,11 +67,11 @@
 {
 	int ivar;
 }
--(void) test3: (Test  [3] [4])b ; 
+-(void) test3: (Test*  [3] [4])b ; 
 @end
 
 @implementation Test
--(void) test3: (Test [3] [4])b {}
+-(void) test3: (Test* [3] [4])b {}
 @end
 
 struct S { int iS; };

Modified: cfe/trunk/test/SemaObjC/interface-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/interface-1.m?rev=70178&r1=70177&r2=70178&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/interface-1.m (original)
+++ cfe/trunk/test/SemaObjC/interface-1.m Sun Apr 26 20:55:56 2009
@@ -20,7 +20,8 @@
 @end
 
 void test2() {
-    INT1 b[3];          // expected-warning {{array of interface 'INT1' should probably be an array of pointers}}
+    // rdar://6827200
+    INT1 b[3];          // expected-error {{array of interface 'INT1' is invalid (probably should be an array of pointers)}}
     INT1 *c = &b[0];
     ++c;
 }





More information about the cfe-commits mailing list