Debian Codegraph @

gcc/testsuite/g++.dg/parse/defarg18.C

raw
1 // PR c++/118319
2 // { dg-do "compile" { target c++11 } }
3
4 // Template case, that used to crash.
5
6 template <int>
7 struct S {
8 friend void foo1 (int a = []{}()); // { dg-error "specifies default|only declaration" }
9 friend void foo3 (int a, // { dg-error "specifies default|only declaration" }
10 int b = []{}(),
11 int c = []{}());
12 };
13
14 void foo1 (int a) {}
15 void foo3 (int a, int b, int c) {}
16
17 void hello (){
18 S<0> t;
19 foo1 ();
20 foo3 (1, 2);
21 }
22
23
24 // Template case, that already worked.
25
26 template <int>
27 struct T {
28 friend void bar (int a = []{}()); // { dg-error "specifies default|only declaration" }
29 };
30
31 void hallo (){
32 T<0> t;
33 bar (); // { dg-error "not declared" }
34 }
35
36
37 // Non template case, that already worked.
38
39 struct NoTemplate {
40 friend void baz (int a = []{}()); // { dg-error "specifies default|could not convert" }
41 };
42
43 void baz (int a) {} // { dg-error "only declaration" }
44
45 void ola (){
46 NoTemplate t;
47 baz (); // { dg-error "void value not ignored" }
48 }