diff options
author | John McCall <rjmccall@apple.com> | 2013-05-06 21:39:12 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2013-05-06 21:39:12 +0000 |
commit | 993f43f24d7a45a5cd4678a3316b0852261fc5d4 (patch) | |
tree | bf54fbd0ff497973e08eb9c0667daaaa43804fb0 /test/Sema | |
parent | 009735db957ac4bcca8f5ad1a5c01354b1b57fbd (diff) |
Grab-bag of bit-field fixes:
- References to ObjC bit-field ivars are bit-field lvalues;
fixes rdar://13794269, which got me started down this.
- Introduce Expr::refersToBitField, switch a couple users to
it where semantically important, and comment the difference
between this and the existing API.
- Discourage Expr::getBitField by making it a bit longer and
less general-sounding.
- Lock down on const_casts of bit-field gl-values until we
hear back from the committee as to whether they're allowed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181252 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema')
-rw-r--r-- | test/Sema/bitfield.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/Sema/bitfield.c b/test/Sema/bitfield.c index a1ce894037..ab05a7773d 100644 --- a/test/Sema/bitfield.c +++ b/test/Sema/bitfield.c @@ -39,3 +39,18 @@ int y; struct PR8025 { double : 2; // expected-error{{anonymous bit-field has non-integral type 'double'}} }; + +struct Test4 { + unsigned bitX : 4; + unsigned bitY : 4; + unsigned var; +}; +void test4(struct Test4 *t) { + (void) sizeof(t->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}} + (void) sizeof((t->bitY)); // expected-error {{invalid application of 'sizeof' to bit-field}} + (void) sizeof(t->bitX = 4); // not a bitfield designator in C + (void) sizeof(t->bitX += 4); // not a bitfield designator in C + (void) sizeof((void) 0, t->bitX); // not a bitfield designator in C + (void) sizeof(t->var ? t->bitX : t->bitY); // not a bitfield designator in C + (void) sizeof(t->var ? t->bitX : t->bitX); // not a bitfield designator in C +} |