Add new test to verify that the array index, limit, and stride are
[official-gcc.git] / gcc / testsuite / gcc.dg / declspec-18.c
blobdd4c262d4cd5b15a7e8d7968bee9dc37e59af74f
1 /* { dg-do compile } */
2 /* { dg-options "-std=gnu89" } */
4 static t1 *a; /* { dg-error "unknown type name 't1'" } */
6 int z; /* { dg-message "previous declaration of 'z'" } */
7 typedef t2 *z; /* { dg-error "unknown type name 't2'" } */
8 /* { dg-error "'z' redeclared " "redeclared" { target *-*-* } 7 } */
10 extern t3 p1(void); /* { dg-error "unknown type name 't3'" } */
11 int p2(const t4 x); /* { dg-error "unknown type name 't4'" } */
12 int p3(const t1 x); /* { dg-error "unknown type name 't1'" } */ /* dup??? */
13 int p4(t5 (*x)(void)); /* { dg-error "unknown type name 't5'" } */
14 int p5(t6 *); /* { dg-error "unknown type name 't6'" } */
15 int p6(t7 x); /* { dg-error "unknown type name 't7'" } */
16 int p7(t8[]); /* { dg-error "unknown type name 't8'" } */
17 int p8(int, t9); /* { dg-error "unknown type name 't9'" } */
19 struct s {
20 const t1 a; /* { dg-error "unknown type name 't1'" } */ /* dup??? */
21 const t10 b; /* { dg-error "unknown type name 't10'" } */
22 int b; /* { dg-error "duplicate member" } */
25 typeof (z) c1;
26 typeof (x1) c2; /* { dg-error "undeclared" "undeclared" } */
27 typeof (const t11) c3; /* { dg-error "unknown type name 't11'" } */
28 typeof (t12 *) c3; /* { dg-error "unknown type name 't12'" "t12" { xfail *-*-* } } */
29 /* { dg-bogus "unknown type name 'x1'" unknown"" { target *-*-* } 26 } */
30 /* { dg-bogus "undeclared" "undeclared" { xfail *-*-* } 28 } */
31 /* { dg-bogus "expected expression before" "expected" { xfail *-*-* } 28 } */
33 int recover1;
35 int s0 = sizeof (z);
36 int s1 = sizeof (x2); /* { dg-error "undeclared" "undeclared" } */
37 int s2 = sizeof (const t13); /* { dg-error "unknown type name 't13'" } */
38 int s3 = sizeof (t14 *); /* { dg-error "unknown type name 't14'" "t14" { xfail *-*-* } } */
40 int recover2;
42 /* { dg-bogus "unknown type name 'x2'" "unknown" { target *-*-* } 36 } */
43 /* { dg-bogus "undeclared" "undeclared" { xfail *-*-* } 38 } */
44 /* { dg-bogus "expected expression before" "expected" { xfail *-*-* } 38 } */
46 int a0 = __alignof__ (z);
47 int a1 = __alignof__ (x3); /* { dg-error "undeclared" } */
48 int a2 = __alignof__ (const t15); /* { dg-error "unknown type name 't15'" } */
49 int a3 = __alignof__ (t16 *); /* { dg-error "unknown type name 't16'" "t16" { xfail *-*-* } } */
51 int recover3;
53 /* { dg-bogus "unknown type name 'x3'" "" { target *-*-* } 47 } */
54 /* { dg-bogus "undeclared" "undeclared" { xfail *-*-* } 49 } */
55 /* { dg-bogus "expected expression before" "expected" { xfail *-*-* } 49 } */
58 /* Cannot detect (undefd_type *) or (undefd_type (*) because it would
59 require 3 tokens of lookahead (same as above). */
61 const char *f1()
63 return (const t17) "abc"; /* { dg-error "unknown type name 't17'" "t17" } */
64 /* { dg-bogus "expected" "expected" { target *-*-* } 63 } */
67 const char *f2()
69 return (const t18 *) "abc"; /* { dg-error "unknown type name 't18'" "t18" } */
70 /* { dg-bogus "expected" "expected" { target *-*-* } 69 } */
74 /* The parser has problems distinguishing semantic and syntactic errors,
75 so it emits a wrong "expected ')'" error here. */
77 void *f3(int x)
79 return (void *) ((void *(*)(t19)) f3); /* { dg-error "unknown type name 't19'" "t19" } */
80 /* { dg-bogus "expected" "expected" { xfail *-*-* } 79 } */
83 const void *f4()
85 return &((const t20){1}); /* { dg-error "unknown type name 't20'" } */
86 /* { dg-bogus "return discards 'const'" "discards" { target *-*-* } 85 } */
87 /* { dg-bogus "expected" "expected" { target *-*-* } 85 } */
90 int f5(__builtin_va_list ap)
92 int x = __builtin_va_arg (ap, t21); /* { dg-error "unknown type name 't21'" } */
93 int y = __builtin_va_arg (ap, const t22); /* { dg-error "unknown type name 't22'" } */
96 int f6(void)
98 return __builtin_offsetof (t23, field); /* { dg-error "unknown type name 't23'" "t23" } */
99 /* { dg-bogus "request for member" "request" { target *-*-* } 98 } */