OSDN Git Service

2012-12-15 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / func-args-1.C
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 "" } */
5
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" } */
11
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;
19
20 void
21 g (int a)
22 {
23   f0();
24   x.f0();
25   f0(a); /* { dg-error "too many arguments to function" } */
26   x.f0(a); /* { dg-error "too many arguments to function" } */
27   f0(a, a); /* { dg-error "too many arguments to function" } */
28   x.f0(a, a); /* { dg-error "too many arguments to function" } */
29   f1(); /* { dg-error "too few arguments to function" } */
30   x.f1(); /* { dg-error "too few arguments to function" } */
31   f1(a);
32   x.f1(a);
33   f1(a, a); /* { dg-error "too many arguments to function" } */
34   x.f1(a, a); /* { dg-error "too many arguments to function" } */
35   f1v(); /* { dg-error "too few arguments to function" } */
36   x.f1v(); /* { dg-error "too few arguments to function" } */
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" } */
42   x.f2(a); /* { dg-error "too few arguments to function" } */
43   f2(a, a);
44   x.f2(a, a);
45   f2(a, a, a); /* { dg-error "too many arguments to function" } */
46   x.f2(a, a, a); /* { dg-error "too many arguments to function" } */
47   f2v(a); /* { dg-error "too few arguments to function" } */
48   x.f2v(a); /* { dg-error "too few arguments to function" } */
49   f2v(a, a);
50   x.f2v(a, a);
51   f2v(a, a, a);
52   x.f2v(a, a, a);
53 }