summaryrefslogtreecommitdiff
path: root/clang/test/Sema/bitfield.c
diff options
context:
space:
mode:
authorZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
committerZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
commit222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch)
tree7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/Sema/bitfield.c
parent3d206f03985b50beacae843d880bccdc91a9f424 (diff)
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/Sema/bitfield.c')
-rw-r--r--clang/test/Sema/bitfield.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/clang/test/Sema/bitfield.c b/clang/test/Sema/bitfield.c
new file mode 100644
index 0000000..a1ce894
--- /dev/null
+++ b/clang/test/Sema/bitfield.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+enum e0; // expected-note{{forward declaration of 'enum e0'}}
+
+struct a {
+ int a : -1; // expected-error{{bit-field 'a' has negative width}}
+
+ // rdar://6081627
+ int b : 33; // expected-error{{size of bit-field 'b' (33 bits) 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}}
+
+ float xx : 4; // expected-error {{bit-field 'xx' has non-integral type}}
+
+ // PR3607
+ enum e0 f : 1; // expected-error {{field has incomplete type 'enum e0'}}
+
+ int g : (_Bool)1;
+
+ // PR4017
+ char : 10; // expected-error {{size of anonymous bit-field (10 bits) exceeds size of its type (8 bits)}}
+ unsigned : -2; // expected-error {{anonymous bit-field has negative width (-2)}}
+ float : 12; // expected-error {{anonymous bit-field has non-integral type 'float'}}
+};
+
+struct b {unsigned x : 2;} x;
+__typeof__(x.x+1) y;
+int y;
+
+struct {unsigned x : 2;} x2;
+__typeof__((x.x+=1)+1) y;
+__typeof__((0,x.x)+1) y;
+__typeof__(x.x<<1) y;
+int y;
+
+struct PR8025 {
+ double : 2; // expected-error{{anonymous bit-field has non-integral type 'double'}}
+};