[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / constexpr-backtrace-limit.cpp
blobe867afdff5c3cf94bb538e0b7c25e4560eab3db8
1 // RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit=0 -fconstexpr-depth=4 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST1
2 // TEST1: constant expression
3 // TEST1-NEXT: exceeded maximum depth of 4
4 // TEST1-NEXT: in call to 'recurse(2)'
5 // TEST1-NEXT: in call to 'recurse(3)'
6 // TEST1-NEXT: in call to 'recurse(4)'
7 // TEST1-NEXT: in call to 'recurse(5)'
9 // RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit=2 -fconstexpr-depth=4 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST2
10 // TEST2: constant expression
11 // TEST2-NEXT: exceeded maximum depth of 4
12 // TEST2-NEXT: in call to 'recurse(2)'
13 // TEST2-NEXT: skipping 2 calls
14 // TEST2-NEXT: in call to 'recurse(5)'
16 // RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit=2 -fconstexpr-depth=8 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST3
17 // TEST3: constant expression
18 // TEST3-NEXT: reinterpret_cast
19 // TEST3-NEXT: in call to 'recurse(0)'
20 // TEST3-NEXT: skipping 4 calls
21 // TEST3-NEXT: in call to 'recurse(5)'
23 // RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit=8 -fconstexpr-depth=8 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST4
24 // TEST4: constant expression
25 // TEST4-NEXT: reinterpret_cast
26 // TEST4-NEXT: in call to 'recurse(0)'
27 // TEST4-NEXT: in call to 'recurse(1)'
28 // TEST4-NEXT: in call to 'recurse(2)'
29 // TEST4-NEXT: in call to 'recurse(3)'
30 // TEST4-NEXT: in call to 'recurse(4)'
31 // TEST4-NEXT: in call to 'recurse(5)'
33 constexpr int recurse(int n) { return n ? recurse(n-1) : *(int*)n; }
34 static_assert(recurse(5), "");