]> granicus.if.org Git - clang/commit
Sema: Do not allow template declarations inside local classes
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 22 Oct 2013 04:14:18 +0000 (04:14 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 22 Oct 2013 04:14:18 +0000 (04:14 +0000)
commit588a51a471b4cb23613e8183e05d2d193d2ab813
tree6694aba70d5968f2b4e245f4fa0b2bfd64f0c312
parent2cfbf0552f90c7ef42975ca1b9064888550ca2ee
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193144 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaTemplate.cpp
test/CXX/temp/temp.decls/temp.mem/p2.cpp [new file with mode: 0644]
test/CodeGenCXX/mangle-local-class-names.cpp
test/PCH/cxx-local-templates.cpp [deleted file]
test/PCH/cxx1y-local-templates.cpp [deleted file]
test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
test/SemaTemplate/local-member-templates.cpp [deleted file]