llvm-project/clang/test/SemaTemplate/instantiation-depth-exception-spec.cpp
Richard Smith 54f18e8a85 PR12298 et al: don't recursively instantiate a template specialization from
within the instantiation of that same specialization. This could previously
happen for eagerly-instantiated function templates, variable templates,
exception specifications, default arguments, and a handful of other cases.

We still have an issue here for default template arguments that recursively
make use of themselves and likewise for substitution into the type of a
non-type template parameter, but in those cases we're producing a different
entity each time, so they should instead be caught by the instantiation depth
limit. However, currently we will typically run out of stack before we reach
it. :(

llvm-svn: 280190
2016-08-31 02:15:21 +00:00

15 lines
570 B
C++

// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -ftemplate-depth 16 -fcxx-exceptions -fexceptions %s
template<int N> struct X {
static int go(int a) noexcept(noexcept(X<N+1>::go(a))); // \
// expected-error {{recursive template instantiation exceeded maximum depth of 16}} \
// expected-note 9{{in instantiation of exception specification}} \
// expected-note {{skipping 7 context}} \
// expected-note {{use -ftemplate-depth}}
};
void f() {
int k = X<0>::go(0); // \
// expected-note {{in instantiation of exception specification for 'go' requested here}}
}