Diagnose ++/-- op on objc pointers in

nonfragile abi, instead of crashing.

llvm-svn: 76088
This commit is contained in:
Fariborz Jahanian 2009-07-16 17:59:14 +00:00
parent dd27e5e10a
commit ca75db7c02
2 changed files with 17 additions and 0 deletions

View File

@ -4603,6 +4603,12 @@ QualType Sema::CheckIncrementDecrementOperand(Expr *Op, SourceLocation OpLoc,
Op->getSourceRange(), SourceRange(),
ResType))
return QualType();
// Diagnose bad cases where we step over interface counts.
else if (PointeeTy->isObjCInterfaceType() && LangOpts.ObjCNonFragileABI) {
Diag(OpLoc, diag::err_arithmetic_nonfragile_interface)
<< PointeeTy << Op->getSourceRange();
return QualType();
}
} else if (ResType->isComplexType()) {
// C99 does not support ++/-- on complex types, we allow as an extension.
Diag(OpLoc, diag::ext_integer_increment_complex)

View File

@ -77,3 +77,14 @@ int bar(I0 *P) {
}
@end
@interface Foo @end
int foo()
{
Foo *f;
// Both of these crash clang nicely
++f; // expected-error {{arithmetic on pointer to interface 'Foo', which is not a constant size in non-fragile ABI}}
--f; // expected-error {{arithmetic on pointer to interface 'Foo', which is not a constant size in non-fragile ABI}}
}