Debian Codegraph @

gcc/testsuite/gcc.dg/too-many-arguments.c

raw
1 /* Ensure that we get an error on the call to fn_a with an
2 int arg below. */
3 /* { dg-additional-options "-std=c23" } */
4
5 /* Verify that the first excess param is underlined. */
6 /* { dg-additional-options "-fdiagnostics-show-caret" } */
7
8 extern void fn_a (); /* { dg-message "declared here" } */
9 extern void fn_b (void); /* { dg-message "declared here" } */
10 extern void fn_c (int); /* { dg-message "declared here" } */
11
12 void test_known_fn (void)
13 {
14 fn_a (42); /* { dg-error "too many arguments to function 'fn_a'; expected 0, have 1" } */
15 /* { dg-begin-multiline-output "" }
16 fn_a (42);
17 ^~~~ ~~
18 { dg-end-multiline-output "" } */
19 /* { dg-begin-multiline-output "" }
20 extern void fn_a ();
21 ^~~~
22 { dg-end-multiline-output "" } */
23
24 fn_b (1776); /* { dg-error "too many arguments to function 'fn_b'; expected 0, have 1" } */
25 /* { dg-begin-multiline-output "" }
26 fn_b (1776);
27 ^~~~ ~~~~
28 { dg-end-multiline-output "" } */
29 /* { dg-begin-multiline-output "" }
30 extern void fn_b (void);
31 ^~~~
32 { dg-end-multiline-output "" } */
33
34 fn_c (1066, 1649); /* { dg-error "too many arguments to function 'fn_c'; expected 1, have 2" } */
35 /* { dg-begin-multiline-output "" }
36 fn_c (1066, 1649);
37 ^~~~ ~~~~
38 { dg-end-multiline-output "" } */
39 /* { dg-begin-multiline-output "" }
40 extern void fn_c (int);
41 ^~~~
42 { dg-end-multiline-output "" } */
43 }
44
45 struct foo
46 {
47 void (*callback_a)(); /* { dg-message "declared here" } */
48 void (*callback_b)(void); /* { dg-message "declared here" } */
49 void (*callback_c)(int); /* { dg-message "declared here" } */
50 };
51
52 void test_callback (struct foo *f)
53 {
54 f->callback_a (42); /* { dg-error "too many arguments to function 'f->callback_a'; expected 0, have 1" } */
55 /* { dg-begin-multiline-output "" }
56 f->callback_a (42);
57 ^ ~~
58 { dg-end-multiline-output "" } */
59 /* { dg-begin-multiline-output "" }
60 void (*callback_a)();
61 ^~~~~~~~~~
62 { dg-end-multiline-output "" } */
63
64 f->callback_b (1776); /* { dg-error "too many arguments to function 'f->callback_b'; expected 0, have 1" } */
65 /* { dg-begin-multiline-output "" }
66 f->callback_b (1776);
67 ^ ~~~~
68 { dg-end-multiline-output "" } */
69 /* { dg-begin-multiline-output "" }
70 void (*callback_b)(void);
71 ^~~~~~~~~~
72 { dg-end-multiline-output "" } */
73
74 f->callback_c (1066, 1649); /* { dg-error "too many arguments to function 'f->callback_c'; expected 1, have 2" } */
75 /* { dg-begin-multiline-output "" }
76 f->callback_c (1066, 1649);
77 ^ ~~~~
78 { dg-end-multiline-output "" } */
79 /* { dg-begin-multiline-output "" }
80 void (*callback_c)(int);
81 ^~~~~~~~~~
82 { dg-end-multiline-output "" } */
83 }