forked from OSchip/llvm-project
warn when someone tries to make an array of ObjC interfaces instead of array
of pointers to them. rdar://4304469 llvm-svn: 54953
This commit is contained in:
parent
22fc2665e6
commit
e5d812af59
|
@ -406,6 +406,8 @@ DIAG(err_objc_missing_end, ERROR,
|
||||||
"missing @end")
|
"missing @end")
|
||||||
DIAG(warn_objc_protocol_qualifier_missing_id, WARNING,
|
DIAG(warn_objc_protocol_qualifier_missing_id, WARNING,
|
||||||
"protocol qualifiers without 'id' is archaic")
|
"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,
|
DIAG(err_objc_illegal_visibility_spec, ERROR,
|
||||||
"illegal visibility specification")
|
"illegal visibility specification")
|
||||||
|
|
|
@ -338,7 +338,11 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
|
||||||
T = Context.IntTy;
|
T = Context.IntTy;
|
||||||
D.setInvalidType(true);
|
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.
|
// C99 6.7.5.2p1: The size expression shall have integer type.
|
||||||
if (ArraySize && !ArraySize->getType()->isIntegerType()) {
|
if (ArraySize && !ArraySize->getType()->isIntegerType()) {
|
||||||
Diag(ArraySize->getLocStart(), diag::err_array_size_non_int,
|
Diag(ArraySize->getLocStart(), diag::err_array_size_non_int,
|
||||||
|
|
|
@ -15,3 +15,13 @@ NSObject // expected-error {{cannot find interface declaration for 'NSObject
|
||||||
@end
|
@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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue