2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
|
2011-11-11 10:00:42 +08:00
|
|
|
|
|
|
|
// PR1892, PR11354
|
|
|
|
void f(double a[restrict][5]) { __typeof(a) x = 10; } // expected-warning {{(aka 'double (*restrict)[5]')}}
|
2008-01-03 06:50:48 +08:00
|
|
|
|
2008-01-29 08:15:50 +08:00
|
|
|
int foo (__const char *__path);
|
|
|
|
int foo(__const char *__restrict __file);
|
|
|
|
|
2008-11-24 07:12:31 +08:00
|
|
|
void func(const char*); // expected-note {{previous declaration is here}}
|
|
|
|
void func(char*); // expected-error{{conflicting types for 'func'}}
|
2008-01-30 02:58:14 +08:00
|
|
|
|
2008-01-14 13:45:46 +08:00
|
|
|
void g(int (*)(const void **, const void **));
|
|
|
|
void g(int (*compar)()) {
|
|
|
|
}
|
|
|
|
|
2008-11-24 07:12:31 +08:00
|
|
|
void h(); // expected-note {{previous declaration is here}}
|
|
|
|
void h (const char *fmt, ...) {} // expected-error{{conflicting types for 'h'}}
|
2008-01-31 14:06:29 +08:00
|
|
|
|
|
|
|
// PR1965
|
|
|
|
int t5(b); // expected-error {{parameter list without types}}
|
2008-04-05 14:32:51 +08:00
|
|
|
int t6(int x, g); // expected-warning {{type specifier missing, defaults to 'int'}}
|
2008-01-31 14:06:29 +08:00
|
|
|
|
2008-02-11 07:08:00 +08:00
|
|
|
int t7(, ); // expected-error {{expected parameter declarator}} expected-error {{expected parameter declarator}}
|
|
|
|
int t8(, int a); // expected-error {{expected parameter declarator}}
|
|
|
|
int t9(int a, ); // expected-error {{expected parameter declarator}}
|
2008-01-31 14:06:29 +08:00
|
|
|
|
|
|
|
|
2008-02-18 03:31:09 +08:00
|
|
|
// PR2042
|
|
|
|
void t10(){}
|
2009-04-02 23:37:10 +08:00
|
|
|
void t11(){t10(1);} // expected-warning{{too many arguments}}
|
2008-02-18 03:31:09 +08:00
|
|
|
|
2008-12-17 15:32:46 +08:00
|
|
|
// PR3208
|
|
|
|
void t12(int) {} // expected-error{{parameter name omitted}}
|
|
|
|
|
2008-12-18 10:01:17 +08:00
|
|
|
// PR2790
|
|
|
|
void t13() {
|
2010-07-12 07:34:02 +08:00
|
|
|
return 0; // expected-error {{void function 't13' should not return a value}}
|
2008-12-18 10:01:17 +08:00
|
|
|
}
|
|
|
|
int t14() {
|
2010-07-12 07:34:02 +08:00
|
|
|
return; // expected-error {{non-void function 't14' should return a value}}
|
2008-12-18 10:01:17 +08:00
|
|
|
}
|
2009-01-24 00:23:13 +08:00
|
|
|
|
|
|
|
// <rdar://problem/6097326>
|
|
|
|
y(y) { return y; } // expected-warning{{parameter 'y' was not declared, defaulting to type 'int'}} \
|
|
|
|
// expected-warning{{type specifier missing, defaults to 'int'}}
|
2009-02-05 02:50:00 +08:00
|
|
|
|
|
|
|
|
2009-02-05 03:10:27 +08:00
|
|
|
// PR3137, <rdar://problem/6127293>
|
2009-02-05 02:50:00 +08:00
|
|
|
extern int g0_3137(void);
|
|
|
|
void f0_3137() {
|
|
|
|
int g0_3137(void);
|
|
|
|
}
|
|
|
|
void f1_3137() {
|
|
|
|
int (*fp)(void) = g0_3137;
|
|
|
|
}
|
2009-02-24 09:23:02 +08:00
|
|
|
|
|
|
|
void f1static() {
|
|
|
|
static void f2static(int); // expected-error{{function declared in block scope cannot have 'static' storage class}}
|
|
|
|
register void f2register(int); // expected-error{{illegal storage class on function}}
|
|
|
|
}
|
2009-03-04 15:30:59 +08:00
|
|
|
|
2009-03-25 03:52:54 +08:00
|
|
|
struct incomplete_test a(void) {} // expected-error{{incomplete result type 'struct incomplete_test' in function definition}} \
|
|
|
|
// expected-note{{forward declaration of 'struct incomplete_test'}}
|
2009-04-15 01:02:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
extern __inline
|
2009-04-28 11:13:54 +08:00
|
|
|
__attribute__((__gnu_inline__))
|
2009-04-15 01:02:11 +08:00
|
|
|
void gnu_inline1() {}
|
|
|
|
|
|
|
|
void
|
2009-04-28 11:13:54 +08:00
|
|
|
__attribute__((__gnu_inline__)) // expected-warning {{'gnu_inline' attribute requires function to be marked 'inline', attribute ignored}}
|
2009-04-15 01:02:11 +08:00
|
|
|
gnu_inline2() {}
|
2009-04-18 03:32:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
// rdar://6802350
|
|
|
|
inline foo_t invalid_type() { // expected-error {{unknown type name 'foo_t'}}
|
|
|
|
}
|
|
|
|
|
2009-04-25 13:51:56 +08:00
|
|
|
typedef void fn_t(void);
|
|
|
|
fn_t t17;
|
|
|
|
|
2009-04-25 14:12:16 +08:00
|
|
|
// PR4049
|
2009-04-25 16:47:54 +08:00
|
|
|
unknown_type t18(void*) { // expected-error {{unknown type name 'unknown_type'}} expected-error{{parameter name omitted}}
|
|
|
|
}
|
|
|
|
|
|
|
|
unknown_type t19(int* P) { // expected-error {{unknown type name 'unknown_type'}}
|
|
|
|
P = P+1; // no warning.
|
2009-04-25 14:12:16 +08:00
|
|
|
}
|
2009-04-18 03:32:54 +08:00
|
|
|
|
2009-09-23 05:41:40 +08:00
|
|
|
// missing ',' before '...'
|
|
|
|
void t20(int i...) { } // expected-error {{requires a comma}}
|
2012-01-14 07:06:53 +08:00
|
|
|
|
|
|
|
int n;
|
|
|
|
void t21(int n, int (*array)[n]);
|