From 9a56882e53cbe26e201d942cd7d1380879b3af86 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 21 Nov 2011 19:36:32 +0000 Subject: Add driver arguments -ftemplate-depth=N and -fconstexpr-depth=N, with the same semantics and defaults as the corresponding g++ arguments. The historical g++ argument -ftemplate-depth-N is kept for compatibility, but modern g++ versions no longer document that option. Add -cc1 argument -fconstexpr-depth N to implement the corresponding functionality. The -ftemplate-depth=N part of this fixes PR9890. llvm-svn: 145045 --- clang/test/SemaCXX/constexpr-depth.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 clang/test/SemaCXX/constexpr-depth.cpp (limited to 'clang/test/SemaCXX/constexpr-depth.cpp') diff --git a/clang/test/SemaCXX/constexpr-depth.cpp b/clang/test/SemaCXX/constexpr-depth.cpp new file mode 100644 index 00000000000..b8ae6682c56 --- /dev/null +++ b/clang/test/SemaCXX/constexpr-depth.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -DMAX=128 -fconstexpr-depth 128 +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -DMAX=1 -fconstexpr-depth 1 +// RUN: %clang -std=c++11 -fsyntax-only -Xclang -verify %s -DMAX=10 -fconstexpr-depth=10 + +constexpr int depth(int n) { return n > 1 ? depth(n-1) : 0; } + +constexpr int kBad = depth(MAX + 1); // expected-error {{must be initialized by a constant expression}} +constexpr int kGood = depth(MAX); -- cgit v1.2.3