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