| 1 |
/* Test error-handling for legacy code that tries to |
| 2 |
define "false" or "true" within enums with C23. */ |
| 3 |
|
| 4 |
/* { dg-do compile } */ |
| 5 |
/* { dg-options "-std=c23" } */ |
| 6 |
|
| 7 |
typedef enum { false = 0, true = 1 } _Bool; /* { dg-error "cannot use keyword 'false' as enumeration constant" } |
| 8 |
/* { dg-message "'false' is a keyword with '-std=c23' onwards" "" { target *-*-* } .-1 } */ |
| 9 |
/* { dg-error "38: expected ';', identifier or '\\\(' before '_Bool'" "" { target *-*-* } .-2 } */ |
| 10 |
/* { dg-warning "38: useless type name in empty declaration" "" { target *-*-* } .-3 } */ |
| 11 |
|
| 12 |
typedef enum { true = 1, false = 0 } _Bool; /* { dg-error "cannot use keyword 'true' as enumeration constant" } |
| 13 |
/* { dg-message "'true' is a keyword with '-std=c23' onwards" "" { target *-*-* } .-1 } */ |
| 14 |
/* { dg-error "38: expected ';', identifier or '\\\(' before '_Bool'" "" { target *-*-* } .-2 } */ |
| 15 |
/* { dg-warning "38: useless type name in empty declaration" "" { target *-*-* } .-3 } */ |
| 16 |
|
| 17 |
typedef enum { False = 0, True = 1 } bool; /* { dg-error "expected ';', identifier or '\\(' before 'bool'" } |
| 18 |
/* { dg-warning "38: useless type name in empty declaration" "" { target *-*-* } .-1 } */ |