Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -verify -fsyntax-only |
Anders Carlsson | 12beab7 | 2009-01-31 19:07:49 +0000 | [diff] [blame] | 2 | |
| 3 | void c1(int *a); |
| 4 | |
Aaron Ballman | c12aaff | 2013-09-11 01:37:41 +0000 | [diff] [blame] | 5 | extern int g1 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}} |
| 6 | int g2 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}} |
| 7 | static int g3 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}} |
Anders Carlsson | 12beab7 | 2009-01-31 19:07:49 +0000 | [diff] [blame] | 8 | |
| 9 | void t1() |
| 10 | { |
Aaron Ballman | b724338 | 2013-07-23 19:30:11 +0000 | [diff] [blame] | 11 | int v1 __attribute((cleanup)); // expected-error {{'cleanup' attribute takes one argument}} |
| 12 | int v2 __attribute((cleanup(1, 2))); // expected-error {{'cleanup' attribute takes one argument}} |
| 13 | |
Aaron Ballman | c12aaff | 2013-09-11 01:37:41 +0000 | [diff] [blame] | 14 | static int v3 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}} |
Aaron Ballman | b724338 | 2013-07-23 19:30:11 +0000 | [diff] [blame] | 15 | |
Aaron Ballman | c12aaff | 2013-09-11 01:37:41 +0000 | [diff] [blame] | 16 | int v4 __attribute((cleanup(h))); // expected-error {{use of undeclared identifier 'h'}} |
Anders Carlsson | 12beab7 | 2009-01-31 19:07:49 +0000 | [diff] [blame] | 17 | |
| 18 | int v5 __attribute((cleanup(c1))); |
| 19 | int v6 __attribute((cleanup(v3))); // expected-error {{'cleanup' argument 'v3' is not a function}} |
| 20 | } |
| 21 | |
| 22 | struct s { |
| 23 | int a, b; |
| 24 | }; |
| 25 | |
| 26 | void c2(); |
Anders Carlsson | 723f55d | 2009-02-07 23:16:50 +0000 | [diff] [blame] | 27 | void c3(struct s a); |
Anders Carlsson | 12beab7 | 2009-01-31 19:07:49 +0000 | [diff] [blame] | 28 | |
| 29 | void t2() |
| 30 | { |
| 31 | int v1 __attribute__((cleanup(c2))); // expected-error {{'cleanup' function 'c2' must take 1 parameter}} |
Anders Carlsson | f2f2e7f | 2009-02-25 17:19:08 +0000 | [diff] [blame] | 32 | int v2 __attribute__((cleanup(c3))); // expected-error {{'cleanup' function 'c3' parameter has type 'struct s' which is incompatible with type 'int *'}} |
Anders Carlsson | 723f55d | 2009-02-07 23:16:50 +0000 | [diff] [blame] | 33 | } |
Eli Friedman | bd0e673 | 2009-04-26 01:30:08 +0000 | [diff] [blame] | 34 | |
| 35 | // This is a manufactured testcase, but gcc accepts it... |
| 36 | void c4(_Bool a); |
| 37 | void t4() { |
| 38 | __attribute((cleanup(c4))) void* g; |
| 39 | } |
| 40 | |
Ted Kremenek | b79ee57 | 2013-12-18 23:30:06 +0000 | [diff] [blame] | 41 | void c5(void*) __attribute__((deprecated)); // expected-note{{'c5' has been explicitly marked deprecated here}} |
Nick Lewycky | a096b14 | 2013-02-12 08:08:54 +0000 | [diff] [blame] | 42 | void t5() { |
| 43 | int i __attribute__((cleanup(c5))); // expected-warning {{'c5' is deprecated}} |
| 44 | } |
Aaron Ballman | c12aaff | 2013-09-11 01:37:41 +0000 | [diff] [blame] | 45 | |
| 46 | void t6(void) { |
| 47 | int i __attribute__((cleanup((void *)0))); // expected-error {{'cleanup' argument is not a function}} |
| 48 | } |