blob: 59ebbfc4599fee2ebb08043c58640cd25815ea59 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 %s -verify -fsyntax-only
Anders Carlssonb95907d2009-01-31 19:07:49 +00002
3void c1(int *a);
4
5extern int g1 __attribute((cleanup(c1))); // expected-warning {{cleanup attribute ignored}}
6int g2 __attribute((cleanup(c1))); // expected-warning {{cleanup attribute ignored}}
7static int g3 __attribute((cleanup(c1))); // expected-warning {{cleanup attribute ignored}}
8
9void t1()
10{
John McCallbdc49d32011-03-02 12:15:05 +000011 int v1 __attribute((cleanup)); // expected-error {{attribute takes one argument}}
12 int v2 __attribute((cleanup(1, 2))); // expected-error {{attribute takes one argument}}
Anders Carlssonb95907d2009-01-31 19:07:49 +000013
14 static int v3 __attribute((cleanup(c1))); // expected-warning {{cleanup attribute ignored}}
15
16 int v4 __attribute((cleanup(h))); // expected-error {{'cleanup' argument 'h' not found}}
17
18 int v5 __attribute((cleanup(c1)));
19 int v6 __attribute((cleanup(v3))); // expected-error {{'cleanup' argument 'v3' is not a function}}
20}
21
22struct s {
23 int a, b;
24};
25
26void c2();
Anders Carlsson89941c12009-02-07 23:16:50 +000027void c3(struct s a);
Anders Carlssonb95907d2009-01-31 19:07:49 +000028
29void t2()
30{
31 int v1 __attribute__((cleanup(c2))); // expected-error {{'cleanup' function 'c2' must take 1 parameter}}
Anders Carlssonb90052a2009-02-25 17:19:08 +000032 int v2 __attribute__((cleanup(c3))); // expected-error {{'cleanup' function 'c3' parameter has type 'struct s' which is incompatible with type 'int *'}}
Anders Carlsson89941c12009-02-07 23:16:50 +000033}
Eli Friedmand5e3e8e2009-04-26 01:30:08 +000034
35// This is a manufactured testcase, but gcc accepts it...
36void c4(_Bool a);
37void t4() {
38 __attribute((cleanup(c4))) void* g;
39}
40