Debian Codegraph @

clang/test/SemaCXX/bitfield.cpp

raw
1 // RUN: %clang_cc1 %s -verify
2 // RUN: %clang_cc1 %s -verify -Wms-bitfield-padding
3
4 // expected-no-diagnostics
5
6 namespace PromotionVersusMutation {
7 typedef unsigned Unsigned;
8 typedef signed Signed;
9
10 struct T { unsigned n : 2; } t;
11
12 typedef __typeof__(t.n) Unsigned; // Bitfield is unsigned
13 typedef __typeof__(+t.n) Signed; // ... but promotes to signed.
14
15 typedef __typeof__(t.n + 0) Signed; // Arithmetic promotes.
16
17 typedef __typeof__(t.n = 0) Unsigned; // Assignment produces an lvalue...
18 typedef __typeof__(t.n += 0) Unsigned;
19 typedef __typeof__(t.n *= 0) Unsigned;
20 typedef __typeof__(+(t.n = 0)) Signed; // ... which is a bit-field.
21 typedef __typeof__(+(t.n += 0)) Signed;
22 typedef __typeof__(+(t.n *= 0)) Signed;
23
24 typedef __typeof__(++t.n) Unsigned; // Increment is equivalent to compound-assignment.
25 typedef __typeof__(--t.n) Unsigned;
26 typedef __typeof__(+(++t.n)) Signed;
27 typedef __typeof__(+(--t.n)) Signed;
28
29 typedef __typeof__(t.n++) Unsigned; // Post-increment's result has the type
30 typedef __typeof__(t.n--) Unsigned; // of the operand...
31 typedef __typeof__(+(t.n++)) Unsigned; // ... and is not a bit-field (because
32 typedef __typeof__(+(t.n--)) Unsigned; // it's not a glvalue).
33 }