Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / warn-constant-evaluated-constexpr.cpp
blob35dc69cccb3a2e299d72386610c9fb2257bf0278
1 // RUN: %clang_cc1 -std=c++2a -fsyntax-only -verify %s
3 namespace std {
4 constexpr bool is_constant_evaluated() noexcept {
5 return __builtin_is_constant_evaluated();
7 } // namespace std
9 constexpr int fn1() {
10 if constexpr (std::is_constant_evaluated()) // expected-warning {{'std::is_constant_evaluated' will always evaluate to 'true' in a manifestly constant-evaluated expression}}
11 return 0;
12 else
13 return 1;
16 constexpr int fn2() {
17 if constexpr (!std::is_constant_evaluated()) // expected-warning {{'std::is_constant_evaluated' will always evaluate to 'true' in a manifestly constant-evaluated expression}}
18 return 0;
19 else
20 return 1;
23 constexpr int fn3() {
24 if constexpr (std::is_constant_evaluated() == false) // expected-warning {{'std::is_constant_evaluated' will always evaluate to 'true' in a manifestly constant-evaluated expression}}
25 return 0;
26 else
27 return 1;
30 constexpr int fn4() {
31 if constexpr (__builtin_is_constant_evaluated() == true) // expected-warning {{'__builtin_is_constant_evaluated' will always evaluate to 'true' in a manifestly constant-evaluated expression}}
32 return 0;
33 else
34 return 1;
37 constexpr int fn5() {
38 if constexpr (__builtin_is_constant_evaluated()) // expected-warning {{'__builtin_is_constant_evaluated' will always evaluate to 'true' in a manifestly constant-evaluated expression}}
39 return 0;
40 else
41 return 1;
44 constexpr int nowarn1() {
45 if (std::is_constant_evaluated())
46 return 0;
47 else
48 return 1;
51 constexpr int nowarn2() {
52 if (!__builtin_is_constant_evaluated())
53 return 0;
54 else
55 return 1;