diff --git a/clang/include/clang/Basic/DiagnosticKinds.def b/clang/include/clang/Basic/DiagnosticKinds.def index 30efa8598169..6eeaffa68356 100644 --- a/clang/include/clang/Basic/DiagnosticKinds.def +++ b/clang/include/clang/Basic/DiagnosticKinds.def @@ -406,6 +406,8 @@ DIAG(err_objc_missing_end, ERROR, "missing @end") DIAG(warn_objc_protocol_qualifier_missing_id, WARNING, "protocol qualifiers without 'id' is archaic") +DIAG(warn_objc_array_of_interfaces, WARNING, + "array of interface '%0' should probably be array of pointers") DIAG(err_objc_illegal_visibility_spec, ERROR, "illegal visibility specification") diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index eafaae5d872b..820a1c85f06a 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -338,7 +338,11 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) { T = Context.IntTy; D.setInvalidType(true); } + } else if (T->isObjCInterfaceType()) { + Diag(DeclType.Loc, diag::warn_objc_array_of_interfaces, + T.getAsString()); } + // C99 6.7.5.2p1: The size expression shall have integer type. if (ArraySize && !ArraySize->getType()->isIntegerType()) { Diag(ArraySize->getLocStart(), diag::err_array_size_non_int, diff --git a/clang/test/SemaObjC/interface-1.m b/clang/test/SemaObjC/interface-1.m index d93f29c4b6e2..31706653f594 100644 --- a/clang/test/SemaObjC/interface-1.m +++ b/clang/test/SemaObjC/interface-1.m @@ -15,3 +15,13 @@ NSObject // expected-error {{cannot find interface declaration for 'NSObject @end +// rdar://4304469 +@interface INT1 +@end + +void test2() { + INT1 b[3]; // expected-warning {{array of interface 'INT1' should probably be array of pointers}} + INT1 *c = &b[0]; + ++c; +} +