gcc/testsuite/g++.dg/opt/is_constant_evaluated1.C
raw| 1 | // PR c++/108243 |
| 2 | // { dg-do compile { target c++11 } } |
| 3 | // { dg-additional-options "-O -fdump-tree-original" } |
| 4 | |
| 5 | struct A { |
| 6 | constexpr A(int n, int m) : n(n), m(m) { } |
| 7 | int n, m; |
| 8 | }; |
| 9 | |
| 10 | constexpr int foo(int n) { |
| 11 | return n + !__builtin_is_constant_evaluated(); |
| 12 | } |
| 13 | |
| 14 | A* f(int n) { |
| 15 | static A a = {n, foo(41)}; |
| 16 | return &a; |
| 17 | } |
| 18 | |
| 19 | // { dg-final { scan-tree-dump "42" "original" } } |
| 20 | // { dg-final { scan-tree-dump-not "foo \\(41\\)" "original" } } |