File tree Expand file tree Collapse file tree 6 files changed +85
-0
lines changed
Expand file tree Collapse file tree 6 files changed +85
-0
lines changed Original file line number Diff line number Diff line change 1+ #include <assert.h>
2+
3+ enum enum1
4+ {
5+ E1
6+ };
7+
8+ enum enum2 : signed char
9+ {
10+ E2
11+ };
12+
13+ typedef signed char signed_char_t ;
14+
15+ enum enum3 : signed_char_t
16+ {
17+ E3
18+ };
19+
20+ int main ()
21+ {
22+ assert (sizeof (int ) != sizeof (signed char ));
23+ assert (sizeof (enum enum1 ) == sizeof (int ));
24+ assert (sizeof (enum enum2 ) == sizeof (signed char ));
25+ assert (sizeof (enum enum3 ) == sizeof (signed char ));
26+
27+ enum enum2 e2 = 0xff ;
28+ assert (e2 == -1 );
29+
30+ enum enum3 e3 = 0xff ;
31+ assert (e3 == -1 );
32+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+
4+ ^EXIT=0$
5+ ^SIGNAL=0$
6+ ^VERIFICATION SUCCESSFUL$
7+ --
8+ ^warning: ignoring
9+ --
10+ Checks that the underlying type specification of an enum is correctly
11+ interpreted, i.e., the size and signedness of the integral type chosen for the
12+ enum is the one specified. Also checks that it works with typedef'd types.
Original file line number Diff line number Diff line change 1+ #include <assert.h>
2+
3+ enum enum1 : unsigned char
4+ {
5+ E1 = 256
6+ };
7+
8+ int main ()
9+ {
10+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+
4+ ^EXIT=6$
5+ ^SIGNAL=0$
6+ ^file main.c line \d+: enumerator value is not representable in the underlying type 'unsigned_char'$
7+ --
8+ ^warning: ignoring
9+ --
10+ Checks that values that cannot be represented by the specified underlying type
11+ are rejected
Original file line number Diff line number Diff line change 1+ #include <assert.h>
2+
3+ enum enum1 : float
4+ {
5+ E1
6+ };
7+
8+ int main ()
9+ {
10+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+
4+ ^EXIT=6$
5+ ^SIGNAL=0$
6+ ^file main.c line \d+: non-integral type 'float' is an invalid underlying type$
7+ --
8+ ^warning: ignoring
9+ --
10+ Checks that non-integral types are rejected
You can’t perform that action at this time.
0 commit comments