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
f1(void * x U)8 static int f1(void *x U) { return 0; }
f2()9 static void f2() { }
f3(void)10 static void f3(void) { } /* { dg-message "note: declared here" } */
f4(void * x U)11 static void f4(void *x U) { }
f5(int * x U)12 static void f5(int *x U) { }
f6(double * x U)13 static void f6(double *x U) { } /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" } */
f7(const int * x U)14 static void f7(const int *x U) { }
f8(const int * x U,int y U)15 static void f8(const int *x U, int y U) { } /* { dg-message "note: declared here" } */
f9(int x U)16 static void f9(int x U) { } /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" } */
17
test(void)18 void 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
35 int o14 C(f1); /* { dg-warning "attribute ignored" } */
t15(int o U C (f1))36 void t15(int o U C(f1)) {} /* { dg-warning "attribute ignored" } */
37