[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / AST / ByteCode / depth-limit.cpp
blob6c21e5e65f0e0339e64c121f6ac6745634108465
1 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fconstexpr-depth=100 -verify %s
2 // RUN: %clang_cc1 -fconstexpr-depth=100 -verify=ref %s
4 constexpr int f(int a) {
5 if (a == 100)
6 return 1 / 0; // expected-warning {{division by zero is undefined}} \
7 // ref-warning {{division by zero is undefined}}
9 return f(a + 1); // ref-note {{exceeded maximum depth of 100 calls}} \
10 // ref-note {{in call to 'f(99)'}} \
11 // ref-note {{in call to 'f(98)'}} \
12 // ref-note {{in call to 'f(97)'}} \
13 // ref-note {{in call to 'f(96)'}} \
14 // ref-note {{in call to 'f(95)'}} \
15 // ref-note {{skipping 90 calls in backtrace}} \
16 // ref-note {{in call to 'f(4)'}} \
17 // ref-note {{in call to 'f(3)'}} \
18 // ref-note {{in call to 'f(2)'}} \
19 // ref-note {{in call to 'f(1)'}} \
20 // expected-note {{exceeded maximum depth of 100 calls}} \
21 // expected-note {{in call to 'f(99)'}} \
22 // expected-note {{in call to 'f(98)'}} \
23 // expected-note {{in call to 'f(97)'}} \
24 // expected-note {{in call to 'f(96)'}} \
25 // expected-note {{in call to 'f(95)'}} \
26 // expected-note {{skipping 90 calls in backtrace}} \
27 // expected-note {{in call to 'f(4)'}} \
28 // expected-note {{in call to 'f(3)'}} \
29 // expected-note {{in call to 'f(2)'}} \
30 // expected-note {{in call to 'f(1)'}}
32 static_assert(f(0) == 100, ""); // ref-error {{not an integral constant expression}} \
33 // ref-note {{in call to 'f(0)'}} \
34 // expected-error {{not an integral constant expression}} \
35 // expected-note {{in call to 'f(0)'}}