From: Chris Lattner Date: Mon, 27 Apr 2009 01:55:56 +0000 (+0000) Subject: rdar://6827200 - [sema] reject statically allocated arrays of interface types X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c7c11b1ba6a110f2416889cc3576fe33277b2a33;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70178 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 7225aadbbc..0e40e3af44 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/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/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 5df0aecd8f..6f9818f350 100644 --- a/lib/Sema/SemaType.cpp +++ b/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/test/CodeGenObjC/encode-test.m b/test/CodeGenObjC/encode-test.m index 6d2f64e436..ca54a51c3b 100644 --- a/test/CodeGenObjC/encode-test.m +++ b/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/test/SemaObjC/interface-1.m b/test/SemaObjC/interface-1.m index 823d1e6061..40734ba800 100644 --- a/test/SemaObjC/interface-1.m +++ b/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; }