diff options
author | David Majnemer <david.majnemer@gmail.com> | 2013-10-22 04:14:18 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2013-10-22 04:14:18 +0000 |
commit | 766e259e38e51c3773fcbd429f1faef52cb1de36 (patch) | |
tree | 7c5844a7d5fe19fceb13cb47331b2eef11cdeeb2 /clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp | |
parent | a93033cc89648a8df95493ca6a1cee4f257ed312 (diff) | |
download | bcm5719-llvm-766e259e38e51c3773fcbd429f1faef52cb1de36.tar.gz bcm5719-llvm-766e259e38e51c3773fcbd429f1faef52cb1de36.zip |
Sema: Do not allow template declarations inside local classes
Summary:
Enforce the rule in C++11 [temp.mem]p2 that local classes cannot have
member templates.
This fixes PR16947.
N.B. C++14 has slightly different wording to afford generic lambdas
declared inside of functions.
Fun fact: Some formulations of local classes with member templates
would cause clang to crash during Itanium mangling, such as the
following:
void outer_mem() {
struct Inner {
template <typename = void>
struct InnerTemplateClass {
static void itc_mem() {}
};
};
Inner::InnerTemplateClass<>::itc_mem();
}
Reviewers: eli.friedman, rsmith, doug.gregor, faisalv
Reviewed By: doug.gregor
CC: cfe-commits, ygao
Differential Revision: http://llvm-reviews.chandlerc.com/D1866
llvm-svn: 193144
Diffstat (limited to 'clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp')
-rw-r--r-- | clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp b/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp index 97bf00303bb..5f43ea2c27a 100644 --- a/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp +++ b/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp @@ -44,13 +44,14 @@ namespace dr1330_example { A<int>().f(42); } + struct S { + template<typename T> + static int f() noexcept(noexcept(A<T>().f("boo!"))) { return 0; } // \ + // expected-note {{instantiation of exception spec}} + typedef decltype(f<S>()) X; + }; + int test2() { - struct S { - template<typename T> - static int f() noexcept(noexcept(A<T>().f("boo!"))) { return 0; } // \ - // expected-note {{instantiation of exception spec}} - typedef decltype(f<S>()) X; - }; S().f<S>(); // ok S().f<int>(); // expected-note {{instantiation of exception spec}} } |