Skip to content

test for bitfield promotion #3713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions regression/cbmc/Bitfields1/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ typedef enum _INTEL_CACHE_TYPE {
} INTEL_CACHE_TYPE;

struct bft {
unsigned int a:3;
unsigned long int a : 3;
unsigned int b:1;
signed int c:2;
_Bool d:3;
_Bool d : 1;

// an anonymous bitfield
signed int :2;
Expand All @@ -20,7 +20,7 @@ struct bft {
INT x:1;

// made of sizeof
unsigned int abc: sizeof(int);
unsigned int abc : sizeof(int) * 8;

// enums are integers!
INTEL_CACHE_TYPE Type : 5;
Expand Down Expand Up @@ -53,7 +53,14 @@ int main() {

// assignments have the underlying type
assert(sizeof(bf.d=1)==sizeof(_Bool));
assert(sizeof(bf.a+=1)==sizeof(unsigned));
assert(sizeof(bf.a += 1) == sizeof(unsigned long));

bf.Type=IntelCacheTrace;

// promotion rules apply, and thus, bf.a is signed,
// but bf.abc is unsigned
bf.a = 0;
assert(bf.a - 1 < 0);
bf.abc = 0;
assert(bf.abc - 1 >= 0);
}
2 changes: 1 addition & 1 deletion regression/cbmc/Bitfields1/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
KNOWNBUG
main.c

^EXIT=0$
Expand Down