blob: 0c7496ac7a27fefd53786e6bb9e0d2568c116dc8 [file] [log] [blame]
Chris Lattner3b427b32007-10-11 00:18:28 +00001/* RUN: clang %s -std=c89 -pedantic -fsyntax-only -verify
Chris Lattnerc30ebfb2007-08-27 04:29:41 +00002 */
Chris Lattner94f81fd2007-08-28 16:54:00 +00003void test1() {
Chris Lattnerc30ebfb2007-08-27 04:29:41 +00004 {
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}
Chris Lattnerb23deda2007-08-28 16:40:32 +000020
Chris Lattner94f81fd2007-08-28 16:54:00 +000021long long test2; /* expected-warning {{extension}} */
Chris Lattnerb23deda2007-08-28 16:40:32 +000022
Chris Lattner94f81fd2007-08-28 16:54:00 +000023
24void test3(int i) {
25 int A[i]; /* expected-warning {{variable length array}} */
26}
Neil Boothb9449512007-08-29 22:00:19 +000027
28int test4 = 0LL; /* expected-warning {{long long}} */
29
Chris Lattner99d724f2008-02-10 23:08:00 +000030/* PR1999 */
31void test5(register);
32
Chris Lattner3e5849e2008-02-15 18:02:59 +000033/* PR2041 */
34int *restrict;
Chris Lattner49581f42008-02-19 06:46:10 +000035int *__restrict; /* expected-error {{expected identifier}} */
Chris Lattnera798ebc2008-04-05 05:52:15 +000036
37
38/* Implicit int, always ok */
Chris Lattnerd658b562008-04-05 06:32:51 +000039test6() {}
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;
Chris Lattner777f07b2008-12-17 07:32:46 +000047int a(sometype, y) {return 0;} /* expected-warning {{declaration specifier missing, defaulting to 'int'}} \
48 expected-error {{parameter name omitted}}*/
Chris Lattnera798ebc2008-04-05 05:52:15 +000049
50
Chris Lattner8123a952008-04-10 02:22:51 +000051
52
53void bar (void *);
54void f11 (z) /* expected-error {{may not have 'void' type}} */
55void z;
56{ bar (&z); }
57
58typedef void T;
Chris Lattnerdef026a2008-04-10 02:26:16 +000059void foo(T); /* typedef for void is allowed */
60
61void foo(void) {}
Chris Lattner8123a952008-04-10 02:22:51 +000062
Chris Lattnera1fcbad2008-12-18 06:50:14 +000063/* 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}