Richard Smith | 08d6e03 | 2011-12-16 19:06:07 +0000 | [diff] [blame] | 1 | // RUN: %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)' |
| 8 | |
| 9 | // RUN: %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)' |
| 15 | |
| 16 | // RUN: %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 |
Richard Smith | b4e85ed | 2012-01-06 16:39:00 +0000 | [diff] [blame] | 18 | // TEST3-NEXT: reinterpret_cast |
Richard Smith | 08d6e03 | 2011-12-16 19:06:07 +0000 | [diff] [blame] | 19 | // TEST3-NEXT: in call to 'recurse(0)' |
| 20 | // TEST3-NEXT: skipping 4 calls |
| 21 | // TEST3-NEXT: in call to 'recurse(5)' |
| 22 | |
| 23 | // RUN: %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 |
Richard Smith | b4e85ed | 2012-01-06 16:39:00 +0000 | [diff] [blame] | 25 | // TEST4-NEXT: reinterpret_cast |
Richard Smith | 08d6e03 | 2011-12-16 19:06:07 +0000 | [diff] [blame] | 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)' |
| 32 | |
| 33 | constexpr int recurse(int n) { return n ? recurse(n-1) : *(int*)n; } |
| 34 | static_assert(recurse(5), ""); |