145
|
1 // { dg-do run }
|
|
2 // { dg-options "-std=c++2a" }
|
|
3
|
|
4 namespace std {
|
|
5 constexpr inline bool
|
|
6 is_constant_evaluated () noexcept
|
|
7 {
|
|
8 return __builtin_is_constant_evaluated ();
|
|
9 }
|
|
10 }
|
|
11
|
|
12 extern "C" void abort ();
|
|
13 constexpr int f0 (int n) { return n; }
|
|
14 consteval int f1 (int n) { return f0 (n) * n; }
|
|
15 consteval int f2 (int n) { return f1 (n); }
|
|
16 consteval bool f3 () { return std::is_constant_evaluated (); }
|
|
17 struct S { constexpr S (int x) : s (x) {} consteval int m1 (int n) const; int s; };
|
|
18 consteval int
|
|
19 S::m1 (int n) const
|
|
20 {
|
|
21 n += s;
|
|
22 return n;
|
|
23 }
|
|
24
|
|
25 constexpr int a = 2;
|
|
26 int b = f1 (a);
|
|
27 int c = f2 (f1 (a));
|
|
28 bool d = f3 ();
|
|
29 constexpr S e = 41;
|
|
30 int f = e.m1 (1);
|
|
31
|
|
32 int
|
|
33 main ()
|
|
34 {
|
|
35 if (b != 4 || c != 16 || !d || f != 42)
|
|
36 abort ();
|
|
37 }
|