35 lines · cpp
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=TEST12// TEST1: constant expression3// TEST1-NEXT: exceeded maximum depth of 44// 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: 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=TEST210// TEST2: constant expression11// TEST2-NEXT: exceeded maximum depth of 412// TEST2-NEXT: in call to 'recurse(2)'13// TEST2-NEXT: skipping 2 calls14// TEST2-NEXT: in call to 'recurse(5)'15 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=TEST317// TEST3: constant expression18// TEST3-NEXT: dereferencing a null pointer19// TEST3-NEXT: in call to 'recurse(0)'20// TEST3-NEXT: skipping 4 calls21// TEST3-NEXT: in call to 'recurse(5)'22 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=TEST424// TEST4: constant expression25// TEST4-NEXT: dereferencing a null pointer26// 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), "");35