]> granicus.if.org Git - clang/commitdiff
rdar://6827200 - [sema] reject statically allocated arrays of interface types
authorChris Lattner <sabre@nondot.org>
Mon, 27 Apr 2009 01:55:56 +0000 (01:55 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 27 Apr 2009 01:55:56 +0000 (01:55 +0000)
Upgrade "array of interface" warning to an error.  In addition to being a
terrible idea, this crashes codegen.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70178 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 7225aadbbc1ec04952f90084c3954302db31694e..0e40e3af44a8fa080312599164ed53e3c393faf6 100644 (file)
@@ -1632,8 +1632,8 @@ def err_missing_type_specifier : Error<
   "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<
index 5df0aecd8fae7713f6994f43daab7f5956262a29..6f9818f3507fb9f8943a434aef109a7ddedee637 100644 (file)
@@ -487,7 +487,8 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
     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.
index 6d2f64e4363bc96e8512f7bb108ac7bc16762117..ca54a51c3b1ce251ecd9edf7a60e119634565af8 100644 (file)
@@ -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@0:4\[3\[4{Test=i}]]8" %t | count 1 &&
+// RUN: grep -e "v12@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 @@ struct Innermost {
 {
        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; };
index 823d1e6061c2ff152dc9660939215c674a35693f..40734ba800ee7fa73f4f8d234b8b23df721c79d4 100644 (file)
@@ -20,7 +20,8 @@ NSObject     // expected-error {{cannot find interface declaration for 'NSObject
 @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;
 }