• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* RUN: %clang_cc1 %s -std=c89 -pedantic -fsyntax-only -verify -Wimplicit-function-declaration
2  */
test1()3 void test1() {
4   {
5     int i;
6     i = i + 1;
7     int j;          /* expected-warning {{mixing declarations and code}} */
8   }
9   {
10     __extension__ int i;
11     i = i + 1;
12     int j;          /* expected-warning {{mixing declarations and code}} */
13   }
14   {
15     int i;
16     i = i + 1;
17     __extension__ int j; /* expected-warning {{mixing declarations and code}} */
18   }
19 }
20 
21 long long test2;   /* expected-warning {{extension}} */
22 
23 
test3(int i)24 void test3(int i) {
25   int A[i];        /* expected-warning {{variable length array}} */
26 }
27 
28 int test4 = 0LL;   /* expected-warning {{long long}} */
29 
30 /* PR1999 */
31 void test5(register);
32 
33 /* PR2041 */
34 int *restrict;
35 int *__restrict;  /* expected-error {{expected identifier}} */
36 
37 
38 /* Implicit int, always ok */
test6()39 test6() { return 0; }
40 
41 /* PR2012 */
42 test7;  /* expected-warning {{declaration specifier missing, defaulting to 'int'}} */
43 
44 void test8(int, x);  /* expected-warning {{declaration specifier missing, defaulting to 'int'}} */
45 
46 typedef int sometype;
a(sometype,y)47 int a(sometype, y) {return 0;}  /* expected-warning {{declaration specifier missing, defaulting to 'int'}} \
48                                    expected-error {{parameter name omitted}}*/
49 
50 
51 
52 
53 void bar (void *);
f11(z)54 void f11 (z)       /* expected-error {{may not have 'void' type}} */
55 void z;
56 { bar (&z); }
57 
58 typedef void T;
59 void foo(T); /* typedef for void is allowed */
60 
foo(void)61 void foo(void) {}
62 
63 /* PR2759 */
64 void test10 (int x[*]); /* expected-warning {{variable length arrays are a C99 feature}} */
65 void test11 (int x[static 4]); /* expected-warning {{static array size is a C99 feature}} */
66 
test12(int x[const4])67 void test12 (int x[const 4]) { /* expected-warning {{qualifier in array size is a C99 feature}} */
68   int Y[x[1]]; /* expected-warning {{variable length arrays are a C99 feature}} */
69 }
70 
71 /* PR4074 */
72 struct test13 {
73   int X[23];
74 } test13a();
75 
test13b()76 void test13b() {
77   int a = test13a().X[1]; /* expected-warning {{ISO C90 does not allow subscripting non-lvalue array}} */
78   int b = 1[test13a().X]; /* expected-warning {{ISO C90 does not allow subscripting non-lvalue array}} */
79 }
80 
81 /* Make sure we allow *test14 as a "function designator" */
test14()82 int test14() { return (&*test14)(); }
83 
84 int test15[5] = { [2] = 1 }; /* expected-warning {{designated initializers are a C99 feature}} */
85 
86 extern int printf(__const char *__restrict __format, ...);
87 
88 /* Warn, but don't suggest typo correction. */
test16()89 void test16() {
90   printg("Hello, world!\n"); /* expected-warning {{implicit declaration of function 'printg'}} */
91 }
92 
93 struct x { int x,y[]; }; /* expected-warning {{flexible array members are a C99 feature}} */
94 
95 /* Duplicated type-qualifiers aren't allowed by C90 */
96 const const int c_i; /* expected-warning {{duplicate 'const' declaration specifier}} */
97 typedef volatile int vol_int;
98 volatile vol_int volvol_i; /* expected-warning {{duplicate 'volatile' declaration specifier}} */
99 typedef volatile vol_int volvol_int; /* expected-warning {{duplicate 'volatile' declaration specifier}} */
100 const int * const c;
101 
102 typedef const int CI;
103 
104 const CI mine1[5][5]; /* expected-warning {{duplicate 'const' declaration specifier}} */
105 
106 typedef CI array_of_CI[5];
107 const array_of_CI mine2; /* expected-warning {{duplicate 'const' declaration specifier}} */
108 
109 typedef CI *array_of_pointer_to_CI[5];
110 const array_of_pointer_to_CI mine3;
111 
main()112 void main() {} /* expected-error {{'main' must return 'int'}} */
113 
main()114 const int main() {} /* expected-error {{'main' must return 'int'}} */
115 
116 long long ll1 = /* expected-warning {{'long long' is an extension when C99 mode is not enabled}} */
117          -42LL; /* expected-warning {{'long long' is an extension when C99 mode is not enabled}} */
118 unsigned long long ull1 = /* expected-warning {{'long long' is an extension when C99 mode is not enabled}} */
119                    42ULL; /* expected-warning {{'long long' is an extension when C99 mode is not enabled}} */
120 
121 struct Test17 { int a; };
122 struct Test17 test17_aux(void);
123 
test17(int v,int w)124 void test17(int v, int w) {
125   int a[2] = { v, w }; /* expected-warning {{initializer for aggregate is not a compile-time constant}} */
126   struct Test17 t0 = { v }; /* expected-warning {{initializer for aggregate is not a compile-time constant}} */
127   struct Test17 t1 = test17_aux(); /* this is allowed */
128 }
129 
130