Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic |
Eli Friedman | 8ac2c66 | 2011-11-11 02:00:42 +0000 | [diff] [blame] | 2 | |
| 3 | // PR1892, PR11354 |
| 4 | void f(double a[restrict][5]) { __typeof(a) x = 10; } // expected-warning {{(aka 'double (*restrict)[5]')}} |
Chris Lattner | 529bd02 | 2008-01-02 22:50:48 +0000 | [diff] [blame] | 5 | |
Steve Naroff | ba03eda | 2008-01-29 00:15:50 +0000 | [diff] [blame] | 6 | int foo (__const char *__path); |
| 7 | int foo(__const char *__restrict __file); |
| 8 | |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 9 | void func(const char*); // expected-note {{previous declaration is here}} |
| 10 | void func(char*); // expected-error{{conflicting types for 'func'}} |
Steve Naroff | 2565eef | 2008-01-29 18:58:14 +0000 | [diff] [blame] | 11 | |
Chris Lattner | 1adb883 | 2008-01-14 05:45:46 +0000 | [diff] [blame] | 12 | void g(int (*)(const void **, const void **)); |
| 13 | void g(int (*compar)()) { |
| 14 | } |
| 15 | |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 16 | void h(); // expected-note {{previous declaration is here}} |
| 17 | void h (const char *fmt, ...) {} // expected-error{{conflicting types for 'h'}} |
Chris Lattner | 868d08f | 2008-01-31 06:06:29 +0000 | [diff] [blame] | 18 | |
| 19 | // PR1965 |
| 20 | int t5(b); // expected-error {{parameter list without types}} |
Chris Lattner | d658b56 | 2008-04-05 06:32:51 +0000 | [diff] [blame] | 21 | int t6(int x, g); // expected-warning {{type specifier missing, defaults to 'int'}} |
Chris Lattner | 868d08f | 2008-01-31 06:06:29 +0000 | [diff] [blame] | 22 | |
Chris Lattner | 99d724f | 2008-02-10 23:08:00 +0000 | [diff] [blame] | 23 | int t7(, ); // expected-error {{expected parameter declarator}} expected-error {{expected parameter declarator}} |
| 24 | int t8(, int a); // expected-error {{expected parameter declarator}} |
| 25 | int t9(int a, ); // expected-error {{expected parameter declarator}} |
Chris Lattner | 868d08f | 2008-01-31 06:06:29 +0000 | [diff] [blame] | 26 | |
| 27 | |
Chris Lattner | 5280408 | 2008-02-17 19:31:09 +0000 | [diff] [blame] | 28 | // PR2042 |
| 29 | void t10(){} |
Douglas Gregor | 74734d5 | 2009-04-02 15:37:10 +0000 | [diff] [blame] | 30 | void t11(){t10(1);} // expected-warning{{too many arguments}} |
Chris Lattner | 5280408 | 2008-02-17 19:31:09 +0000 | [diff] [blame] | 31 | |
Chris Lattner | 777f07b | 2008-12-17 07:32:46 +0000 | [diff] [blame] | 32 | // PR3208 |
| 33 | void t12(int) {} // expected-error{{parameter name omitted}} |
| 34 | |
Chris Lattner | 65ce04b | 2008-12-18 02:01:17 +0000 | [diff] [blame] | 35 | // PR2790 |
| 36 | void t13() { |
Chris Lattner | 184aa4e | 2010-07-11 23:34:02 +0000 | [diff] [blame] | 37 | return 0; // expected-error {{void function 't13' should not return a value}} |
Chris Lattner | 65ce04b | 2008-12-18 02:01:17 +0000 | [diff] [blame] | 38 | } |
| 39 | int t14() { |
Chris Lattner | 184aa4e | 2010-07-11 23:34:02 +0000 | [diff] [blame] | 40 | return; // expected-error {{non-void function 't14' should return a value}} |
Chris Lattner | 65ce04b | 2008-12-18 02:01:17 +0000 | [diff] [blame] | 41 | } |
Douglas Gregor | be109b3 | 2009-01-23 16:23:13 +0000 | [diff] [blame] | 42 | |
| 43 | // <rdar://problem/6097326> |
| 44 | y(y) { return y; } // expected-warning{{parameter 'y' was not declared, defaulting to type 'int'}} \ |
| 45 | // expected-warning{{type specifier missing, defaults to 'int'}} |
Eli Friedman | 0e8aaaf | 2009-02-04 18:50:00 +0000 | [diff] [blame] | 46 | |
| 47 | |
Douglas Gregor | 18d76c2 | 2009-02-04 19:10:27 +0000 | [diff] [blame] | 48 | // PR3137, <rdar://problem/6127293> |
Eli Friedman | 0e8aaaf | 2009-02-04 18:50:00 +0000 | [diff] [blame] | 49 | extern int g0_3137(void); |
| 50 | void f0_3137() { |
| 51 | int g0_3137(void); |
| 52 | } |
| 53 | void f1_3137() { |
| 54 | int (*fp)(void) = g0_3137; |
| 55 | } |
Douglas Gregor | 04495c8 | 2009-02-24 01:23:02 +0000 | [diff] [blame] | 56 | |
| 57 | void f1static() { |
| 58 | static void f2static(int); // expected-error{{function declared in block scope cannot have 'static' storage class}} |
| 59 | register void f2register(int); // expected-error{{illegal storage class on function}} |
| 60 | } |
Eli Friedman | 7f0f5dc | 2009-03-04 07:30:59 +0000 | [diff] [blame] | 61 | |
Douglas Gregor | e7450f5 | 2009-03-24 19:52:54 +0000 | [diff] [blame] | 62 | struct incomplete_test a(void) {} // expected-error{{incomplete result type 'struct incomplete_test' in function definition}} \ |
| 63 | // expected-note{{forward declaration of 'struct incomplete_test'}} |
Chris Lattner | c519743 | 2009-04-14 17:02:11 +0000 | [diff] [blame] | 64 | |
| 65 | |
| 66 | extern __inline |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 67 | __attribute__((__gnu_inline__)) |
Chris Lattner | c519743 | 2009-04-14 17:02:11 +0000 | [diff] [blame] | 68 | void gnu_inline1() {} |
| 69 | |
| 70 | void |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 71 | __attribute__((__gnu_inline__)) // expected-warning {{'gnu_inline' attribute requires function to be marked 'inline', attribute ignored}} |
Chris Lattner | c519743 | 2009-04-14 17:02:11 +0000 | [diff] [blame] | 72 | gnu_inline2() {} |
Chris Lattner | 23a48cc | 2009-04-17 19:32:54 +0000 | [diff] [blame] | 73 | |
| 74 | |
| 75 | // rdar://6802350 |
| 76 | inline foo_t invalid_type() { // expected-error {{unknown type name 'foo_t'}} |
| 77 | } |
| 78 | |
Chris Lattner | 7cbeef2 | 2009-04-25 05:51:56 +0000 | [diff] [blame] | 79 | typedef void fn_t(void); |
| 80 | fn_t t17; |
| 81 | |
Chris Lattner | 2dbd285 | 2009-04-25 06:12:16 +0000 | [diff] [blame] | 82 | // PR4049 |
Chris Lattner | 5153ee6 | 2009-04-25 08:47:54 +0000 | [diff] [blame] | 83 | unknown_type t18(void*) { // expected-error {{unknown type name 'unknown_type'}} expected-error{{parameter name omitted}} |
| 84 | } |
| 85 | |
| 86 | unknown_type t19(int* P) { // expected-error {{unknown type name 'unknown_type'}} |
| 87 | P = P+1; // no warning. |
Chris Lattner | 2dbd285 | 2009-04-25 06:12:16 +0000 | [diff] [blame] | 88 | } |
Chris Lattner | 23a48cc | 2009-04-17 19:32:54 +0000 | [diff] [blame] | 89 | |
Douglas Gregor | ed5d651 | 2009-09-22 21:41:40 +0000 | [diff] [blame] | 90 | // missing ',' before '...' |
| 91 | void t20(int i...) { } // expected-error {{requires a comma}} |
Douglas Gregor | 117c456 | 2012-01-13 23:06:53 +0000 | [diff] [blame] | 92 | |
| 93 | int n; |
| 94 | void t21(int n, int (*array)[n]); |