1 // RUN: %clang_cc1 -std=c++2a -fsyntax-only -verify %s 2 3 namespace std { is_constant_evaluated()4constexpr bool is_constant_evaluated() noexcept { 5 return __builtin_is_constant_evaluated(); 6 } 7 } // namespace std 8 fn1()9constexpr 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; 14 } 15 fn2()16constexpr 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; 21 } 22 fn3()23constexpr 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; 28 } 29 fn4()30constexpr 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; 35 } 36 fn5()37constexpr 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; 42 } 43 nowarn1()44constexpr int nowarn1() { 45 if (std::is_constant_evaluated()) 46 return 0; 47 else 48 return 1; 49 } 50 nowarn2()51constexpr int nowarn2() { 52 if (!__builtin_is_constant_evaluated()) 53 return 0; 54 else 55 return 1; 56 } 57