diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-11-21 19:36:32 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-11-21 19:36:32 +0000 |
commit | 9a56882e53cbe26e201d942cd7d1380879b3af86 (patch) | |
tree | 47190003bb529db90af8bb73733450bea760b67f /clang/test/SemaCXX/constexpr-depth.cpp | |
parent | aa2a00db35735930d97983335afe3ea98430332f (diff) | |
download | bcm5719-llvm-9a56882e53cbe26e201d942cd7d1380879b3af86.tar.gz bcm5719-llvm-9a56882e53cbe26e201d942cd7d1380879b3af86.zip |
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
Diffstat (limited to 'clang/test/SemaCXX/constexpr-depth.cpp')
-rw-r--r-- | clang/test/SemaCXX/constexpr-depth.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
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); |