]> granicus.if.org Git - clang/commitdiff
Avoid issuing spurious errors as side-effect of diagnosing
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 24 Apr 2009 17:34:33 +0000 (17:34 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 24 Apr 2009 17:34:33 +0000 (17:34 +0000)
application of sizeof on an interface.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69980 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaObjC/sizeof-interface.m

index edf769b2fe4d4dc6ccdbc016ef518f1dc85742f1..949c4ae66413d18f9e3a0b799e08f59cdff8e87e 100644 (file)
@@ -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;
index 17931676731658f0a237cf9eba9d24ee364c96cb..a1d722b74294d74c632ca872999c88972ed8d1ab 100644 (file)
@@ -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
+