Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/paren-init20.C

raw
1 // PR c++/92878 - Parenthesized init of aggregates in new-expression.
2 // { dg-do compile { target c++20 } }
3 // Test new TYPE(...).
4
5 int f ();
6
7 struct A
8 {
9 int a;
10 int b;
11 };
12
13 void
14 fn_A ()
15 {
16 int i = 0;
17 auto y = new A(1, 2);
18 auto x = new A(++i, ++i);
19 auto z = new A(1, { ++i });
20 auto u = new A(1, f());
21 }
22
23 struct B
24 {
25 int a;
26 int b;
27 int c = 42;
28 };
29
30 void
31 fn_B ()
32 {
33 int i = 0;
34 auto y = new B(1, 2);
35 auto x = new B(++i, ++i);
36 auto z = new B(1, { ++i });
37 auto u = new B(1, f());
38 }
39
40 struct C
41 {
42 int a;
43 int b = 10;
44 };
45
46 void
47 fn_C ()
48 {
49 int i = 0;
50 auto y = new C(1);
51 auto x = new C(++i);
52 auto z = new C({ ++i });
53 auto u = new C(f());
54 }