aboutsummaryrefslogtreecommitdiff
path: root/test/SemaTemplate/instantiation-depth-subst.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-07-08 02:38:24 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-07-08 02:38:24 +0000
commitab91ef1dbe524bba3c0147b11dfdd394153c783d (patch)
tree8e6d5b141b68afa348ef25365edda4cdf835f5f8 /test/SemaTemplate/instantiation-depth-subst.cpp
parent3a7bd67c06d83b6fdc1cfe8295d28c5dbc5e07ba (diff)
PR9793: Treat substitution as an instantiation step for the purpose of the
-ftemplate-depth limit. There are various ways to get an infinite (or merely huge) stack of substitutions with no intervening instantiations. This is also consistent with gcc's behavior. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159907 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate/instantiation-depth-subst.cpp')
-rw-r--r--test/SemaTemplate/instantiation-depth-subst.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/SemaTemplate/instantiation-depth-subst.cpp b/test/SemaTemplate/instantiation-depth-subst.cpp
new file mode 100644
index 0000000000..58e637411c
--- /dev/null
+++ b/test/SemaTemplate/instantiation-depth-subst.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -ftemplate-depth 2
+
+// PR9793
+template<typename T> auto f(T t) -> decltype(f(t)); // \
+// expected-error {{recursive template instantiation exceeded maximum depth of 2}} \
+// expected-note 3 {{while substituting}} \
+// expected-note {{candidate}}
+
+int k = f(0); // expected-error {{no matching function for call to 'f'}}