Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s -pedantic -std=c99 |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 3 | int __attribute__(()) x; |
Chris Lattner | 7399ee0 | 2008-10-20 02:05:46 +0000 | [diff] [blame] | 4 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 5 | __inline void __attribute__((__always_inline__, __nodebug__)) |
Chris Lattner | 7399ee0 | 2008-10-20 02:05:46 +0000 | [diff] [blame] | 6 | foo(void) { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 7 | } |
Chris Lattner | 7399ee0 | 2008-10-20 02:05:46 +0000 | [diff] [blame] | 8 | |
| 9 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 10 | __attribute__(()) y; // expected-warning {{defaults to 'int'}} |
Chris Lattner | 7399ee0 | 2008-10-20 02:05:46 +0000 | [diff] [blame] | 11 | |
| 12 | // PR2796 |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 13 | int (__attribute__(()) *z)(long y); |
Chris Lattner | 7399ee0 | 2008-10-20 02:05:46 +0000 | [diff] [blame] | 14 | |
| 15 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 16 | void f1(__attribute__(()) int x); |
Chris Lattner | 7399ee0 | 2008-10-20 02:05:46 +0000 | [diff] [blame] | 17 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 18 | int f2(y, __attribute__(()) x); // expected-error {{expected identifier}} |
Chris Lattner | 7399ee0 | 2008-10-20 02:05:46 +0000 | [diff] [blame] | 19 | |
| 20 | // This is parsed as a normal argument list (with two args that are implicit |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 21 | // int) because the __attribute__ is a declspec. |
| 22 | void f3(__attribute__(()) x, // expected-warning {{defaults to 'int'}} |
Chris Lattner | 7399ee0 | 2008-10-20 02:05:46 +0000 | [diff] [blame] | 23 | y); // expected-warning {{defaults to 'int'}} |
| 24 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 25 | void f4(__attribute__(())); // expected-error {{expected parameter declarator}} |
Chris Lattner | 7399ee0 | 2008-10-20 02:05:46 +0000 | [diff] [blame] | 26 | |
| 27 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 28 | // This is ok, the __attribute__ applies to the pointer. |
| 29 | int baz(int (__attribute__(()) *x)(long y)); |
Chris Lattner | 7399ee0 | 2008-10-20 02:05:46 +0000 | [diff] [blame] | 30 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 31 | void g1(void (*f1)(__attribute__(()) int x)); |
| 32 | void g2(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}} |
| 33 | void g3(void (*f3)(__attribute__(()) x, int y)); // expected-warning {{defaults to 'int'}} |
| 34 | void g4(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}} |
Chris Lattner | 7399ee0 | 2008-10-20 02:05:46 +0000 | [diff] [blame] | 35 | |
| 36 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 37 | void (*h1)(void (*f1)(__attribute__(()) int x)); |
| 38 | void (*h2)(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}} |
Chris Lattner | 7399ee0 | 2008-10-20 02:05:46 +0000 | [diff] [blame] | 39 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 40 | void (*h3)(void (*f3)(__attribute__(()) x)); // expected-warning {{defaults to 'int'}} |
| 41 | void (*h4)(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}} |
Chris Lattner | aab740a | 2008-10-20 04:57:38 +0000 | [diff] [blame] | 42 | |
| 43 | |
| 44 | |
| 45 | // rdar://6131260 |
| 46 | int foo42(void) { |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 47 | int x, __attribute__((unused)) y, z; |
Chris Lattner | aab740a | 2008-10-20 04:57:38 +0000 | [diff] [blame] | 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | // rdar://6096491 |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 52 | void __attribute__((noreturn)) d0(void), __attribute__((noreturn)) d1(void); |
Chris Lattner | aab740a | 2008-10-20 04:57:38 +0000 | [diff] [blame] | 53 | |