annotate gcc/testsuite/g++.dg/cpp1y/pr79937-5.C @ 19:2b5abeee2509 default tip

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
1 // PR c++/79937
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
2 // This is a constexpr adaptation of pr79937-3.C and pr79937-4.C.
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
3 // { dg-do compile { target c++14 } }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
4
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
5 struct X {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
6 unsigned i;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
7 unsigned n = i;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
8 };
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
9
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
10 constexpr X bar(X x) {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
11 return x;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
12 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
13
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
14 struct Y
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
15 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
16 static constexpr Y bar(Y y) { return y; }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
17 unsigned i;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
18 unsigned n = bar(Y{2,i}).n;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
19 };
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
20
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
21 constexpr X x { 1, bar(X{2}).n };
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
22 static_assert(x.n == 2, "");
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
23
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
24 constexpr Y y { 1 };
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
25 static_assert(y.n == 1, "");
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
26
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
27 struct Z {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
28 unsigned i;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
29 unsigned n = i;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
30 unsigned m = i;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
31 };
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
32
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
33 constexpr Z
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
34 baz (Z z)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
35 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
36 if (z.i != 1 || z.n != 2 || z.m != 1)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
37 __builtin_abort ();
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
38 return z;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
39 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
40
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
41 constexpr Z z = baz (Z {1, Z {2}.n});
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
42 static_assert(z.i == 1 && z.n == 2 && z.m == 1, "");