1f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -verify -fsyntax-only 2f4a2713aSLionel Sambuc 3f4a2713aSLionel Sambuc void c1(int *a); 4f4a2713aSLionel Sambuc 5f4a2713aSLionel Sambuc extern int g1 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}} 6f4a2713aSLionel Sambuc int g2 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}} 7f4a2713aSLionel Sambuc static int g3 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}} 8f4a2713aSLionel Sambuc t1()9f4a2713aSLionel Sambucvoid t1() 10f4a2713aSLionel Sambuc { 11f4a2713aSLionel Sambuc int v1 __attribute((cleanup)); // expected-error {{'cleanup' attribute takes one argument}} 12f4a2713aSLionel Sambuc int v2 __attribute((cleanup(1, 2))); // expected-error {{'cleanup' attribute takes one argument}} 13f4a2713aSLionel Sambuc 14f4a2713aSLionel Sambuc static int v3 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}} 15f4a2713aSLionel Sambuc 16f4a2713aSLionel Sambuc int v4 __attribute((cleanup(h))); // expected-error {{use of undeclared identifier 'h'}} 17f4a2713aSLionel Sambuc 18f4a2713aSLionel Sambuc int v5 __attribute((cleanup(c1))); 19f4a2713aSLionel Sambuc int v6 __attribute((cleanup(v3))); // expected-error {{'cleanup' argument 'v3' is not a function}} 20f4a2713aSLionel Sambuc } 21f4a2713aSLionel Sambuc 22f4a2713aSLionel Sambuc struct s { 23f4a2713aSLionel Sambuc int a, b; 24f4a2713aSLionel Sambuc }; 25f4a2713aSLionel Sambuc 26f4a2713aSLionel Sambuc void c2(); 27f4a2713aSLionel Sambuc void c3(struct s a); 28f4a2713aSLionel Sambuc t2()29f4a2713aSLionel Sambucvoid t2() 30f4a2713aSLionel Sambuc { 31f4a2713aSLionel Sambuc int v1 __attribute__((cleanup(c2))); // expected-error {{'cleanup' function 'c2' must take 1 parameter}} 32f4a2713aSLionel Sambuc int v2 __attribute__((cleanup(c3))); // expected-error {{'cleanup' function 'c3' parameter has type 'struct s' which is incompatible with type 'int *'}} 33f4a2713aSLionel Sambuc } 34f4a2713aSLionel Sambuc 35f4a2713aSLionel Sambuc // This is a manufactured testcase, but gcc accepts it... 36f4a2713aSLionel Sambuc void c4(_Bool a); t4()37f4a2713aSLionel Sambucvoid t4() { 38f4a2713aSLionel Sambuc __attribute((cleanup(c4))) void* g; 39f4a2713aSLionel Sambuc } 40f4a2713aSLionel Sambuc 41*0a6a1f1dSLionel Sambuc void c5(void*) __attribute__((deprecated)); // expected-note{{'c5' has been explicitly marked deprecated here}} t5()42f4a2713aSLionel Sambucvoid t5() { 43f4a2713aSLionel Sambuc int i __attribute__((cleanup(c5))); // expected-warning {{'c5' is deprecated}} 44f4a2713aSLionel Sambuc } 45f4a2713aSLionel Sambuc t6(void)46f4a2713aSLionel Sambucvoid t6(void) { 47f4a2713aSLionel Sambuc int i __attribute__((cleanup((void *)0))); // expected-error {{'cleanup' argument is not a function}} 48f4a2713aSLionel Sambuc } 49