1 /* Test typedef redeclaration in C11. */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c11 -pedantic-errors" } */
5 /* C11 permits typedefs to be redeclared to the same type, but not to
6 different-but-compatible types, and not when the type is variably
16 enum e
{ E1
= 0, E2
= INT_MAX
, E3
= -1 };
18 typedef enum e TE
; /* { dg-message "previous declaration" } */
19 typedef int TE
; /* { dg-error "with different type" } */
27 typedef TI2 IA
[]; /* { dg-message "previous declaration" } */
29 typedef TI A2
[2]; /* { dg-message "previous declaration" } */
30 typedef IA A2
; /* { dg-error "with different type" } */
32 typedef A3 IA
; /* { dg-error "with different type" } */
35 typedef void F(TI
); /* { dg-message "previous declaration" } */
36 typedef void F(enum e
); /* { dg-error "with different type" } */
39 typedef TI
G(void); /* { dg-message "previous declaration" } */
40 typedef enum e
G(void); /* { dg-error "with different type" } */
43 typedef TI
*P
; /* { dg-message "previous declaration" } */
44 typedef enum e
*P
; /* { dg-error "with different type" } */
47 typedef void F2(); /* { dg-message "previous declaration" } */
48 typedef void F2(int); /* { dg-error "with different type" } */
55 typedef void FN(int (*p
)[a
]);
56 typedef void FN(int (*p
)[b
]);
57 typedef void FN(int (*p
)[*]); /* { dg-message "previous declaration" } */
58 typedef void FN(int (*p
)[1]); /* { dg-error "with different type" } */
59 typedef void FN2(int (*p
)[a
]);
60 typedef void FN2(int (*p
)[b
]);
61 typedef void FN2(int (*p
)[*]); /* { dg-message "previous declaration" } */
62 typedef void FN2(int (*p
)[]); /* { dg-error "with different type" } */
63 typedef int AV
[a
]; /* { dg-message "previous declaration" } */
64 typedef int AV
[b
-1]; /* { dg-error "redefinition" } */
65 typedef int AAa
[a
]; /* { dg-message "previous declaration" } */
67 typedef AAa
*VF(void); /* { dg-message "previous declaration" } */
68 typedef AAb
*VF(void); /* { dg-error "redefinition" } */
69 typedef AAa AAa
; /* { dg-error "redefinition" } */