1 |
689 |
jeremybenn |
/* Test declaration specifiers. Test empty declarations. Test with
|
2 |
|
|
-pedantic-errors. */
|
3 |
|
|
/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
|
4 |
|
|
/* { dg-do compile } */
|
5 |
|
|
/* { dg-options "-pedantic-errors" } */
|
6 |
|
|
|
7 |
|
|
/* If a declaration does not declare a declarator, it must declare a
|
8 |
|
|
tag or the members of an enumeration, and must only contain one
|
9 |
|
|
type specifier. */
|
10 |
|
|
|
11 |
|
|
typedef int T;
|
12 |
|
|
|
13 |
|
|
struct s0;
|
14 |
|
|
union u0;
|
15 |
|
|
enum e0; /* { dg-error "ISO C forbids forward references" } */
|
16 |
|
|
enum { E0 };
|
17 |
|
|
enum e1 { E1 };
|
18 |
|
|
|
19 |
|
|
/* Not declaring anything (pedwarns). */
|
20 |
|
|
struct { int a; }; /* { dg-error "unnamed struct/union that defines no instances" } */
|
21 |
|
|
int; /* { dg-error "useless type name in empty declaration" } */
|
22 |
|
|
long; /* { dg-error "useless type name in empty declaration" } */
|
23 |
|
|
T; /* { dg-error "useless type name in empty declaration" } */
|
24 |
|
|
static const; /* { dg-warning "useless storage class specifier in empty declaration" } */
|
25 |
|
|
/* { dg-error "empty declaration" "static const" { target *-*-* } 24 } */
|
26 |
|
|
union { long b; }; /* { dg-error "unnamed struct/union that defines no instances" } */
|
27 |
|
|
|
28 |
|
|
/* Multiple type names (errors). */
|
29 |
|
|
struct s1 int; /* { dg-error "two or more data types in declaration specifiers" } */
|
30 |
|
|
char union u1; /* { dg-error "two or more data types in declaration specifiers" } */
|
31 |
|
|
/* { dg-error "useless type name in empty declaration" "char union" { target *-*-* } 30 } */
|
32 |
|
|
double enum { E2 }; /* { dg-error "two or more data types in declaration specifiers" } */
|
33 |
|
|
/* { dg-error "useless type name in empty declaration" "double enum" { target *-*-* } 32 } */
|
34 |
|
|
T struct s2; /* { dg-error "two or more data types in declaration specifiers" } */
|
35 |
|
|
/* { dg-error "useless type name in empty declaration" "T struct" { target *-*-* } 34 } */
|
36 |
|
|
long union u2; /* { dg-error "two or more data types in declaration specifiers" } */
|
37 |
|
|
/* { dg-error "useless type name in empty declaration" "empty" { target *-*-* } 36 } */
|
38 |
|
|
struct s3 short; /* { dg-error "two or more data types in declaration specifiers" } */
|
39 |
|
|
union u3 signed; /* { dg-error "two or more data types in declaration specifiers" } */
|
40 |
|
|
unsigned struct s4; /* { dg-error "two or more data types in declaration specifiers" } */
|
41 |
|
|
/* { dg-error "useless type name in empty declaration" "empty" { target *-*-* } 40 } */
|
42 |
|
|
_Complex enum { E3 }; /* { dg-error "two or more data types in declaration specifiers" } */
|
43 |
|
|
/* { dg-error "useless type name in empty declaration" "empty" { target *-*-* } 42 } */
|
44 |
|
|
/* { dg-error "ISO C90 does not support complex types" "C90" { target *-*-* } 42 } */
|
45 |
|
|
/* { dg-error "ISO C does not support plain 'complex' meaning 'double complex'" "ISO C" { target *-*-* } 42 } */
|