blob: 64a26cf2999200f68b3ab95364e43bef656579cf [file] [log] [blame]
Rafael Espindola925213b2013-07-04 16:16:58 +00001// 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
Richard Smithf6f003a2011-12-16 19:06:07 +00002// 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
Rafael Espindola925213b2013-07-04 16:16:58 +00009// 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
Richard Smithf6f003a2011-12-16 19:06:07 +000010// 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
Rafael Espindola925213b2013-07-04 16:16:58 +000016// 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
Richard Smithf6f003a2011-12-16 19:06:07 +000017// TEST3: constant expression
Richard Smitha8105bc2012-01-06 16:39:00 +000018// TEST3-NEXT: reinterpret_cast
Richard Smithf6f003a2011-12-16 19:06:07 +000019// TEST3-NEXT: in call to 'recurse(0)'
20// TEST3-NEXT: skipping 4 calls
21// TEST3-NEXT: in call to 'recurse(5)'
22
Rafael Espindola925213b2013-07-04 16:16:58 +000023// 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
Richard Smithf6f003a2011-12-16 19:06:07 +000024// TEST4: constant expression
Richard Smitha8105bc2012-01-06 16:39:00 +000025// TEST4-NEXT: reinterpret_cast
Richard Smithf6f003a2011-12-16 19:06:07 +000026// 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
33constexpr int recurse(int n) { return n ? recurse(n-1) : *(int*)n; }
34static_assert(recurse(5), "");