forked from OSchip/llvm-project
Diagnose ++/-- op on objc pointers in
nonfragile abi, instead of crashing. llvm-svn: 76088
This commit is contained in:
parent
dd27e5e10a
commit
ca75db7c02
|
@ -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)
|
||||
|
|
|
@ -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}}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue