1/* { dg-do compile } */
2/* { dg-options "-Wall" } */
3/* Validate expected warnings and errors.  */
4
5#define U	__attribute__((unused))
6#define C(x)	__attribute__((cleanup(x)))
7
8static int f1(void *x U) { return 0; }
9static void f2() { }
10static void f3(void) { }
11static void f4(void *x U) { }
12static void f5(int *x U) { }
13static void f6(double *x U) { }
14static void f7(const int *x U) { }
15static void f8(const int *x U, int y U) { }
16static void f9(int x U) { }
17
18void test(void)
19{
20  int o1 C(f1);
21  int o2 C(f2);
22  int o3 C(f3);		/* { dg-error "too many arguments" } */
23  int o4 C(f4);
24  int o5 C(f5);
25  int o6 C(f6);		/* { dg-warning "incompatible pointer type" } */
26  int o7 C(f7);
27  int o8 C(f8);		/* { dg-error "too few arguments" } */
28  int o9 C(f9);		/* { dg-warning "from pointer without a cast" } */
29  int o10 U C(undef);	/* { dg-error "not a function" } */
30  int o11 U C(o1);	/* { dg-error "not a function" } */
31  int o12 U C("f1");	/* { dg-error "not an identifier" } */
32  static int o13 U C(f1); /* { dg-warning "attribute ignored" } */
33}
34
35int o14 C(f1);		/* { dg-warning "attribute ignored" } */
36void t15(int o U C(f1)) {} /* { dg-warning "attribute ignored" } */
37