Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / AST / Interp / if.cpp
blob86ae8de6f73ebb7ec321c402320cd83e7cc9ac1b
1 // RUN: %clang_cc1 -std=c++23 -fsyntax-only -fexperimental-new-constant-interpreter %s -verify
2 // RUN: %clang_cc1 -std=c++23 -fsyntax-only %s -verify=ref
4 // expected-no-diagnostics
5 // ref-no-diagnostics
7 namespace ConstEval {
8 constexpr int f() {
9 int i = 0;
10 if consteval {
11 i = 1;
13 return i;
15 static_assert(f() == 1, "");
17 constexpr int f2() {
18 int i = 0;
19 if !consteval {
20 i = 12;
21 if consteval {
22 i = i + 1;
25 return i;
27 static_assert(f2() == 0, "");
30 namespace InitDecl {
31 constexpr bool f() {
32 if (int i = 5; i != 10) {
33 return true;
35 return false;
37 static_assert(f(), "");
39 constexpr bool f2() {
40 if (bool b = false; b) {
41 return true;
43 return false;
45 static_assert(!f2(), "");
48 constexpr int attrs() {
49 if (1) [[likely]] {}
50 return 1;
52 static_assert(attrs() == 1, "");