2018-05-17 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / func-args-1.c
blob5f7b24535516e56ab24f628f53b605775276d208
1 /* Test messages for wrong number of arguments to function. */
2 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */
3 /* { dg-do compile } */
4 /* { dg-options "" } */
6 void f0(void); /* { dg-message "note: declared here" } */
7 void f1(int); /* { dg-message "note: declared here" } */
8 void f1v(int, ...); /* { dg-message "note: declared here" } */
9 void f2(int, int); /* { dg-message "note: declared here" } */
10 void f2v(int, int, ...); /* { dg-message "note: declared here" } */
12 struct s {
13 void (*f0)(void);
14 void (*f1)(int);
15 void (*f1v)(int, ...);
16 void (*f2)(int, int);
17 void (*f2v)(int, int, ...);
18 } x;
20 void
21 g (int a)
23 f0();
24 x.f0();
25 f0(a); /* { dg-error "too many arguments to function 'f0'" } */
26 x.f0(a); /* { dg-error "too many arguments to function 'x.f0'" } */
27 f0(a, a); /* { dg-error "too many arguments to function 'f0'" } */
28 x.f0(a, a); /* { dg-error "too many arguments to function 'x.f0'" } */
29 f1(); /* { dg-error "too few arguments to function 'f1'" } */
30 x.f1(); /* { dg-error "too few arguments to function 'x.f1'" } */
31 f1(a);
32 x.f1(a);
33 f1(a, a); /* { dg-error "too many arguments to function 'f1'" } */
34 x.f1(a, a); /* { dg-error "too many arguments to function 'x.f1'" } */
35 f1v(); /* { dg-error "too few arguments to function 'f1v'" } */
36 x.f1v(); /* { dg-error "too few arguments to function 'x.f1v'" } */
37 f1v(a);
38 x.f1v(a);
39 f1v(a, a);
40 x.f1v(a, a);
41 f2(a); /* { dg-error "too few arguments to function 'f2'" } */
42 x.f2(a); /* { dg-error "too few arguments to function 'x.f2'" } */
43 f2(a, a);
44 x.f2(a, a);
45 f2(a, a, a); /* { dg-error "too many arguments to function 'f2'" } */
46 x.f2(a, a, a); /* { dg-error "too many arguments to function 'x.f2'" } */
47 f2v(a); /* { dg-error "too few arguments to function 'f2v'" } */
48 x.f2v(a); /* { dg-error "too few arguments to function 'x.f2v'" } */
49 f2v(a, a);
50 x.f2v(a, a);
51 f2v(a, a, a);
52 x.f2v(a, a, a);