c89.c revision d1969d803cfcc65f1c334df4cc89c7fdd33ee4c9
1/* RUN: clang-cc %s -std=c89 -pedantic -fsyntax-only -verify
2 */
3void 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
21long long test2;   /* expected-warning {{extension}} */
22
23
24void test3(int i) {
25  int A[i];        /* expected-warning {{variable length array}} */
26}
27
28int test4 = 0LL;		/* expected-warning {{long long}} */
29
30/* PR1999 */
31void test5(register);
32
33/* PR2041 */
34int *restrict;
35int *__restrict;  /* expected-error {{expected identifier}} */
36
37
38/* Implicit int, always ok */
39test6() { return 0; }
40
41/* PR2012 */
42test7;  /* expected-warning {{declaration specifier missing, defaulting to 'int'}} */
43
44void test8(int, x);  /* expected-warning {{declaration specifier missing, defaulting to 'int'}} */
45
46typedef int sometype;
47int a(sometype, y) {return 0;}  /* expected-warning {{declaration specifier missing, defaulting to 'int'}} \
48                                   expected-error {{parameter name omitted}}*/
49
50
51
52
53void bar (void *);
54void f11 (z)       /* expected-error {{may not have 'void' type}} */
55void z;
56{ bar (&z); }
57
58typedef void T;
59void foo(T); /* typedef for void is allowed */
60
61void foo(void) {}
62
63/* PR2759 */
64void test10 (int x[*]); /* expected-warning {{use of C99-specific array features}} */
65void test11 (int x[static 4]); /* expected-warning {{use of C99-specific array features}} */
66
67void test12 (int x[const 4]) { /* expected-warning {{use of C99-specific array features}} */
68  int Y[x[1]]; /* expected-warning {{variable length arrays are a C99 feature, accepted as an extension}} */
69}
70
71/* PR4074 */
72struct test13 {
73  int X[23];
74} test13a();
75
76void 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" */
82int test14() { return (&*test14)(); }
83