summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-27 01:55:56 +0000
committerChris Lattner <sabre@nondot.org>2009-04-27 01:55:56 +0000
commit669e32f8c0d1f123b4748d9c7cb7e212fe4d8202 (patch)
treed45cb8db90c43e4c728507ce3f2cfbd06d3f4b6c
parent9a845896712365f3f1371eb28a7ea1d7e773d09c (diff)
downloadbcm5719-llvm-669e32f8c0d1f123b4748d9c7cb7e212fe4d8202.tar.gz
bcm5719-llvm-669e32f8c0d1f123b4748d9c7cb7e212fe4d8202.zip
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. llvm-svn: 70178
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td4
-rw-r--r--clang/lib/Sema/SemaType.cpp3
-rw-r--r--clang/test/CodeGenObjC/encode-test.m6
-rw-r--r--clang/test/SemaObjC/interface-1.m3
4 files changed, 9 insertions, 7 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 7225aadbbc1..0e40e3af44a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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<
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 5df0aecd8fa..6f9818f3507 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -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.
diff --git a/clang/test/CodeGenObjC/encode-test.m b/clang/test/CodeGenObjC/encode-test.m
index 6d2f64e4363..ca54a51c3b1 100644
--- a/clang/test/CodeGenObjC/encode-test.m
+++ b/clang/test/CodeGenObjC/encode-test.m
@@ -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; };
diff --git a/clang/test/SemaObjC/interface-1.m b/clang/test/SemaObjC/interface-1.m
index 823d1e6061c..40734ba800e 100644
--- a/clang/test/SemaObjC/interface-1.m
+++ b/clang/test/SemaObjC/interface-1.m
@@ -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;
}
OpenPOWER on IntegriCloud