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