Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/cpp2a/is-constant-evaluated10.C @ 152:2b5abeee2509
update gcc11
author | anatofuz |
---|---|
date | Mon, 25 May 2020 07:50:57 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
145:1830386684a0 | 152:2b5abeee2509 |
---|---|
1 // { dg-do compile { target c++2a } } | |
2 // { dg-options "-Wtautological-compare" } | |
3 | |
4 namespace std { | |
5 constexpr inline bool | |
6 is_constant_evaluated () noexcept | |
7 { | |
8 return __builtin_is_constant_evaluated (); | |
9 } | |
10 } | |
11 | |
12 template<typename> | |
13 constexpr int | |
14 foo(int i) | |
15 { | |
16 if constexpr (std::is_constant_evaluated ()) // { dg-warning ".std::is_constant_evaluated. always evaluates to true in .if constexpr." } | |
17 return 42; | |
18 else | |
19 return i; | |
20 } | |
21 | |
22 template<typename> | |
23 constexpr int | |
24 foo2(int i) | |
25 { | |
26 if constexpr (__builtin_is_constant_evaluated ()) // { dg-warning ".std::is_constant_evaluated. always evaluates to true in .if constexpr." } | |
27 return 42; | |
28 else | |
29 return i; | |
30 } |