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.
29 lines
395 B
C++
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;
|
|
}
|
|
}
|