Debian Codegraph @

gcc/testsuite/g++.dg/diagnostic/missing-default-args.C

raw
1 // { dg-options "-fdiagnostics-show-caret" }
2
3 /* Function. */
4
5 void test_1 (int a, int b = 42, int c, int d); // { dg-line test_1 }
6
7 // { dg-error "default argument missing for parameter 3 of " "" { target *-*-* } test_1 }
8 /* { dg-begin-multiline-output "" }
9 void test_1 (int a, int b = 42, int c, int d);
10 ~~~~^
11 { dg-end-multiline-output "" } */
12 // { dg-message "...following parameter 2 which has a default argument" "" { target *-*-* } test_1 }
13 /* { dg-begin-multiline-output "" }
14 void test_1 (int a, int b = 42, int c, int d);
15 ~~~~^~~~~~
16 { dg-end-multiline-output "" } */
17 // { dg-error "default argument missing for parameter 4 of " "" { target *-*-* } test_1 }
18 /* { dg-begin-multiline-output "" }
19 void test_1 (int a, int b = 42, int c, int d);
20 ~~~~^
21 { dg-end-multiline-output "" } */
22
23
24 /* Non-static member fn. */
25
26 struct test_2
27 {
28 void member_2 (int a, int b = 42, int c); // { dg-line test_2 }
29 };
30 // { dg-error "default argument missing for parameter 3 of " "" { target *-*-* } test_2 }
31 /* { dg-begin-multiline-output "" }
32 void member_2 (int a, int b = 42, int c);
33 ~~~~^
34 { dg-end-multiline-output "" } */
35 // { dg-message "...following parameter 2 which has a default argument" "" { target *-*-* } test_2 }
36 /* { dg-begin-multiline-output "" }
37 void member_2 (int a, int b = 42, int c);
38 ~~~~^~~~~~
39 { dg-end-multiline-output "" } */
40
41
42 /* Static member fn. */
43
44 struct test_3
45 {
46 static void member_3 (int a, int b = 42, int c); // { dg-line test_3 }
47 };
48 // { dg-error "default argument missing for parameter 3 of " "" { target *-*-* } test_3 }
49 /* { dg-begin-multiline-output "" }
50 static void member_3 (int a, int b = 42, int c);
51 ~~~~^
52 { dg-end-multiline-output "" } */
53 // { dg-message "...following parameter 2 which has a default argument" "" { target *-*-* } test_3 }
54 /* { dg-begin-multiline-output "" }
55 static void member_3 (int a, int b = 42, int c);
56 ~~~~^~~~~~
57 { dg-end-multiline-output "" } */
58
59
60 /* Template. */
61
62 template <typename Type>
63 void test_4 (int a, int b = 42, int c); // { dg-line test_4 }
64 // { dg-error "default argument missing for parameter 3 of " "" { target *-*-* } test_4 }
65 /* { dg-begin-multiline-output "" }
66 void test_4 (int a, int b = 42, int c);
67 ~~~~^
68 { dg-end-multiline-output "" } */
69 // { dg-message "...following parameter 2 which has a default argument" "" { target *-*-* } test_4 }
70 /* { dg-begin-multiline-output "" }
71 void test_4 (int a, int b = 42, int c);
72 ~~~~^~~~~~
73 { dg-end-multiline-output "" } */