[cfe-commits] r65128 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaObjC/class-bitfield.m

Steve Naroff snaroff at apple.com
Fri Feb 20 09:57:12 PST 2009


Author: snaroff
Date: Fri Feb 20 11:57:11 2009
New Revision: 65128

URL: http://llvm.org/viewvc/llvm-project?rev=65128&view=rev
Log:
Fix <rdar://problem/6586239> bitfield constraints not enforced (for ObjC)

Added:
    cfe/trunk/test/SemaObjC/class-bitfield.m
Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=65128&r1=65127&r2=65128&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Feb 20 11:57:11 2009
@@ -3572,12 +3572,9 @@
   bool InvalidDecl = false;
   
   if (BitWidth) {
-    // TODO: Validate.
-    //printf("WARNING: BITFIELDS IGNORED!\n");
-    
-    // 6.7.2.1p3
-    // 6.7.2.1p4
-    
+    // 6.7.2.1p3, 6.7.2.1p4
+    if (VerifyBitField(Loc, II, T, BitWidth))
+      InvalidDecl = true;
   } else {
     // Not a bitfield.
     

Added: cfe/trunk/test/SemaObjC/class-bitfield.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/class-bitfield.m?rev=65128&view=auto

==============================================================================
--- cfe/trunk/test/SemaObjC/class-bitfield.m (added)
+++ cfe/trunk/test/SemaObjC/class-bitfield.m Fri Feb 20 11:57:11 2009
@@ -0,0 +1,17 @@
+// RUN: clang %s -fsyntax-only -verify 
+
+ at interface X 
+{
+  int a : -1; // expected-error{{bit-field 'a' has negative width}}
+
+  // rdar://6081627
+  int b : 33; // expected-error{{size of bit-field 'b' exceeds size of its type (32 bits)}}
+
+  int c : (1 + 0.25); // expected-error{{expression is not an integer constant expression}}
+  int d : (int)(1 + 0.25); 
+
+  // rdar://6138816
+  int e : 0;  // expected-error {{bit-field 'e' has zero width}}
+}
+ at end
+





More information about the cfe-commits mailing list