| 1 |
/* PR 30260 */ |
| 2 |
/* { dg-do link } */ |
| 3 |
/* { dg-options "-std=gnu11 -pedantic -O" } */ |
| 4 |
#include <limits.h> |
| 5 |
|
| 6 |
void link_error (void); |
| 7 |
|
| 8 |
enum A { |
| 9 |
A1 = 0, |
| 10 |
A2 = A1 - 1 |
| 11 |
}; |
| 12 |
enum B { |
| 13 |
B1 = 0u, |
| 14 |
B2 = B1 - 1 /* { dg-bogus "ISO C restricts enumerator values to range of 'int'" } */ |
| 15 |
}; |
| 16 |
int main(void) |
| 17 |
{ |
| 18 |
enum A a = -1; |
| 19 |
enum B b = -1; |
| 20 |
|
| 21 |
if (!(a < 0)) |
| 22 |
link_error (); |
| 23 |
if (!(A2 < 0)) |
| 24 |
link_error (); |
| 25 |
if (!(b < 0)) |
| 26 |
link_error (); |
| 27 |
if (!(B2 < 0)) |
| 28 |
link_error (); |
| 29 |
|
| 30 |
return 0; |
| 31 |
} |
| 32 |
|
| 33 |
enum E1 { e10 = INT_MAX, e11 }; /* { dg-warning "ISO C restricts enumerator values to range of 'int' before C23" } */ |
| 34 |
enum E2 { e20 = (unsigned) INT_MAX, e21 }; /* { dg-warning "ISO C restricts enumerator values to range of 'int' before C23" } */ |