llvm-project/clang/test/AST/ByteCode/constexpr-steps.cpp
Timm Baeder f71e321966
[clang][bytecode] Implement constexpr step limit (#176150)
This only calls `noteStep()` on jump opcodes, so this works for loops.
It does not prevent "hangs" when a function is just _very_ long (could
be interesting how this interfaces with expand statements?).

Fixes https://github.com/llvm/llvm-project/issues/165951
2026-02-09 12:22:48 +01:00

11 lines
427 B
C++

// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s -fconstexpr-steps=100
constexpr int foo() { // expected-error {{never produces a constant expression}}
while (1) {} // expected-note 2{{constexpr evaluation hit maximum step limit}}
return 0;
}
static_assert (foo() == 0, ""); // expected-error {{not an integral constant expression}} \
// expected-note {{in call to}}