aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-04-24 17:34:33 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-04-24 17:34:33 +0000
commitced1e286765b4a1c568c8bf2ca41d863bf1584dd (patch)
tree3dd7197648979eeb3b94700934aa0cf94cfbfce2
parent8c2f2d1849247ebf7b2c0dbf1ebba15fe163664b (diff)
Avoid issuing spurious errors as side-effect of diagnosing
application of sizeof on an interface. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69980 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaExpr.cpp4
-rw-r--r--test/SemaObjC/sizeof-interface.m19
2 files changed, 21 insertions, 2 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index edf769b2fe..949c4ae664 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1251,10 +1251,10 @@ bool Sema::CheckSizeOfAlignOfOperand(QualType exprType,
return true;
// Reject sizeof(interface) and sizeof(interface<proto>) in 64-bit mode.
- if (exprType->isObjCInterfaceType() && LangOpts.ObjCNonFragileABI) {
+ if (LangOpts.ObjCNonFragileABI && exprType->isObjCInterfaceType()) {
Diag(OpLoc, diag::err_sizeof_nonfragile_interface)
<< exprType << isSizeof;
- return true;
+ return false;
}
return false;
diff --git a/test/SemaObjC/sizeof-interface.m b/test/SemaObjC/sizeof-interface.m
index 1793167673..a1d722b742 100644
--- a/test/SemaObjC/sizeof-interface.m
+++ b/test/SemaObjC/sizeof-interface.m
@@ -52,3 +52,22 @@ int bar(I0 *P) {
return P[4].x[2]; // expected-error {{subscript requires size of interface 'I0', which is not constant in non-fragile ABI}}
}
+
+@interface I @end
+
+@interface XCAttributeRunDirectNode
+{
+ @public
+ unsigned long attributeRuns[1024 + sizeof(I)]; // expected-error {{invalid application of 'sizeof' to interface 'I' in non-fragile ABI}}
+ int i;
+}
+@end
+
+@implementation XCAttributeRunDirectNode
+
+- (unsigned long)gatherStats:(id )stats
+{
+ return attributeRuns[i];
+}
+@end
+