Files
clang-p2996/clang/test/AST/Interp/if_consteval.cpp
Corentin Jabot 424733c12a Implement if consteval (P1938)
Modify the IfStmt node to suppoort constant evaluated expressions.

Add a new ExpressionEvaluationContext::ImmediateFunctionContext to
keep track of immediate function contexts.

This proved easier/better/probably more efficient than walking the AST
backward as it allows diagnosing nested if consteval statements.
2021-10-05 08:04:14 -04:00

29 lines
395 B
C++

// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fexperimental-new-constant-interpreter %s -verify
// RUN: %clang_cc1 -std=c++2b -fsyntax-only %s -verify
// expected-no-diagnostics
constexpr void f() {
int i = 0;
if consteval {
i = 1;
}
else {
i = 2;
}
if consteval {
i = 1;
}
if !consteval {
i = 1;
}
if !consteval {
i = 1;
}
else {
i = 1;
}
}