2007-10-11 08:18:28 +08:00
|
|
|
/* RUN: clang %s -std=c89 -pedantic -fsyntax-only -verify
|
2007-08-27 12:29:41 +08:00
|
|
|
*/
|
2007-08-29 00:54:00 +08:00
|
|
|
void test1() {
|
2007-08-27 12:29:41 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
i = i + 1;
|
|
|
|
int j; /* expected-warning {{mixing declarations and code}} */
|
|
|
|
}
|
|
|
|
{
|
|
|
|
__extension__ int i;
|
|
|
|
i = i + 1;
|
|
|
|
int j; /* expected-warning {{mixing declarations and code}} */
|
|
|
|
}
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
i = i + 1;
|
|
|
|
__extension__ int j; /* expected-warning {{mixing declarations and code}} */
|
|
|
|
}
|
|
|
|
}
|
2007-08-29 00:40:32 +08:00
|
|
|
|
2007-08-29 00:54:00 +08:00
|
|
|
long long test2; /* expected-warning {{extension}} */
|
2007-08-29 00:40:32 +08:00
|
|
|
|
2007-08-29 00:54:00 +08:00
|
|
|
|
|
|
|
void test3(int i) {
|
|
|
|
int A[i]; /* expected-warning {{variable length array}} */
|
|
|
|
}
|
2007-08-30 06:00:19 +08:00
|
|
|
|
|
|
|
int test4 = 0LL; /* expected-warning {{long long}} */
|
|
|
|
|
2008-02-11 07:08:00 +08:00
|
|
|
/* PR1999 */
|
|
|
|
void test5(register);
|
|
|
|
|
2008-02-16 02:02:59 +08:00
|
|
|
/* PR2041 */
|
|
|
|
int *restrict;
|
2008-02-19 14:46:10 +08:00
|
|
|
int *__restrict; /* expected-error {{expected identifier}} */
|
2008-04-05 13:52:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* Implicit int, always ok */
|
2008-04-05 14:32:51 +08:00
|
|
|
test6() {}
|
|
|
|
|
|
|
|
/* PR2012 */
|
|
|
|
test7; /* expected-warning {{declaration specifier missing, defaulting to 'int'}} */
|
|
|
|
|
|
|
|
void test8(int, x); /* expected-warning {{declaration specifier missing, defaulting to 'int'}} */
|
|
|
|
|
|
|
|
typedef int sometype;
|
2008-12-17 15:32:46 +08:00
|
|
|
int a(sometype, y) {return 0;} /* expected-warning {{declaration specifier missing, defaulting to 'int'}} \
|
|
|
|
expected-error {{parameter name omitted}}*/
|
2008-04-05 13:52:15 +08:00
|
|
|
|
|
|
|
|
2008-04-10 10:22:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
void bar (void *);
|
|
|
|
void f11 (z) /* expected-error {{may not have 'void' type}} */
|
|
|
|
void z;
|
|
|
|
{ bar (&z); }
|
|
|
|
|
|
|
|
typedef void T;
|
2008-04-10 10:26:16 +08:00
|
|
|
void foo(T); /* typedef for void is allowed */
|
|
|
|
|
|
|
|
void foo(void) {}
|
2008-04-10 10:22:51 +08:00
|
|
|
|
2008-12-18 14:50:14 +08:00
|
|
|
/* PR2759 */
|
|
|
|
void test10 (int x[*]); /* expected-warning {{use of C99-specific array features}} */
|
|
|
|
void test11 (int x[static 4]); /* expected-warning {{use of C99-specific array features}} */
|
|
|
|
|
|
|
|
void test12 (int x[const 4]) { /* expected-warning {{use of C99-specific array features}} */
|
|
|
|
int Y[x[1]]; /* expected-warning {{variable length arrays are a C99 feature, accepted as an extension}} */
|
|
|
|
}
|