annotate gcc/testsuite/gcc.dg/c11-typedef-1.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test typedef redeclaration in C11. */
kono
parents:
diff changeset
2 /* { dg-do compile } */
kono
parents:
diff changeset
3 /* { dg-options "-std=c11 -pedantic-errors" } */
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 /* C11 permits typedefs to be redeclared to the same type, but not to
kono
parents:
diff changeset
6 different-but-compatible types, and not when the type is variably
kono
parents:
diff changeset
7 modified. */
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 #include <limits.h>
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 typedef int TI;
kono
parents:
diff changeset
12 typedef int TI2;
kono
parents:
diff changeset
13 typedef TI2 TI;
kono
parents:
diff changeset
14 typedef TI TI2;
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 enum e { E1 = 0, E2 = INT_MAX, E3 = -1 };
kono
parents:
diff changeset
17 typedef enum e TE;
kono
parents:
diff changeset
18 typedef enum e TE; /* { dg-message "previous declaration" } */
kono
parents:
diff changeset
19 typedef int TE; /* { dg-error "with different type" } */
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 struct s;
kono
parents:
diff changeset
22 typedef struct s TS;
kono
parents:
diff changeset
23 struct s { int i; };
kono
parents:
diff changeset
24 typedef struct s TS;
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 typedef int IA[];
kono
parents:
diff changeset
27 typedef TI2 IA[]; /* { dg-message "previous declaration" } */
kono
parents:
diff changeset
28 typedef int A2[2];
kono
parents:
diff changeset
29 typedef TI A2[2]; /* { dg-message "previous declaration" } */
kono
parents:
diff changeset
30 typedef IA A2; /* { dg-error "with different type" } */
kono
parents:
diff changeset
31 typedef int A3[3];
kono
parents:
diff changeset
32 typedef A3 IA; /* { dg-error "with different type" } */
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 typedef void F(int);
kono
parents:
diff changeset
35 typedef void F(TI); /* { dg-message "previous declaration" } */
kono
parents:
diff changeset
36 typedef void F(enum e); /* { dg-error "with different type" } */
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 typedef int G(void);
kono
parents:
diff changeset
39 typedef TI G(void); /* { dg-message "previous declaration" } */
kono
parents:
diff changeset
40 typedef enum e G(void); /* { dg-error "with different type" } */
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 typedef int *P;
kono
parents:
diff changeset
43 typedef TI *P; /* { dg-message "previous declaration" } */
kono
parents:
diff changeset
44 typedef enum e *P; /* { dg-error "with different type" } */
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 typedef void F2();
kono
parents:
diff changeset
47 typedef void F2(); /* { dg-message "previous declaration" } */
kono
parents:
diff changeset
48 typedef void F2(int); /* { dg-error "with different type" } */
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 void
kono
parents:
diff changeset
51 f (void)
kono
parents:
diff changeset
52 {
kono
parents:
diff changeset
53 int a = 1;
kono
parents:
diff changeset
54 int b = 2;
kono
parents:
diff changeset
55 typedef void FN(int (*p)[a]);
kono
parents:
diff changeset
56 typedef void FN(int (*p)[b]);
kono
parents:
diff changeset
57 typedef void FN(int (*p)[*]); /* { dg-message "previous declaration" } */
kono
parents:
diff changeset
58 typedef void FN(int (*p)[1]); /* { dg-error "with different type" } */
kono
parents:
diff changeset
59 typedef void FN2(int (*p)[a]);
kono
parents:
diff changeset
60 typedef void FN2(int (*p)[b]);
kono
parents:
diff changeset
61 typedef void FN2(int (*p)[*]); /* { dg-message "previous declaration" } */
kono
parents:
diff changeset
62 typedef void FN2(int (*p)[]); /* { dg-error "with different type" } */
kono
parents:
diff changeset
63 typedef int AV[a]; /* { dg-message "previous declaration" } */
kono
parents:
diff changeset
64 typedef int AV[b-1]; /* { dg-error "redefinition" } */
kono
parents:
diff changeset
65 typedef int AAa[a]; /* { dg-message "previous declaration" } */
kono
parents:
diff changeset
66 typedef int AAb[b-1];
kono
parents:
diff changeset
67 typedef AAa *VF(void); /* { dg-message "previous declaration" } */
kono
parents:
diff changeset
68 typedef AAb *VF(void); /* { dg-error "redefinition" } */
kono
parents:
diff changeset
69 typedef AAa AAa; /* { dg-error "redefinition" } */
kono
parents:
diff changeset
70 }