diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-02-02 16:35:43 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-02-02 16:35:43 +0000 |
| commit | 35e6fee3e9a0c7ee1828fbfb31da08298d9881f8 (patch) | |
| tree | fc2e9382bffc4b3baf8cade53ed19c8d92e60b6d /clang/lib/Sema/SemaTemplate.cpp | |
| parent | 3a7cc81d52f9b7a6e7e94c9efcd1113f1aeb8c9a (diff) | |
| download | bcm5719-llvm-35e6fee3e9a0c7ee1828fbfb31da08298d9881f8.tar.gz bcm5719-llvm-35e6fee3e9a0c7ee1828fbfb31da08298d9881f8.zip | |
Sema: Reject templates in all extern "C" contexts.
Otherwise we'd accept them if the LinkageDecl was not the direct
parent DeclContext. PR17968.
llvm-svn: 200641
Diffstat (limited to 'clang/lib/Sema/SemaTemplate.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 008ed2755c2..bc66fdedb6b 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -5453,18 +5453,19 @@ Sema::CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams) { (S->getFlags() & Scope::TemplateParamScope) != 0) S = S->getParent(); - // C++ [temp]p2: - // A template-declaration can appear only as a namespace scope or - // class scope declaration. + // C++ [temp]p4: + // A template [...] shall not have C linkage. DeclContext *Ctx = S->getEntity(); - if (Ctx && isa<LinkageSpecDecl>(Ctx) && - cast<LinkageSpecDecl>(Ctx)->getLanguage() != LinkageSpecDecl::lang_cxx) + if (Ctx && Ctx->isExternCContext()) return Diag(TemplateParams->getTemplateLoc(), diag::err_template_linkage) << TemplateParams->getSourceRange(); while (Ctx && isa<LinkageSpecDecl>(Ctx)) Ctx = Ctx->getParent(); + // C++ [temp]p2: + // A template-declaration can appear only as a namespace scope or + // class scope declaration. if (Ctx) { if (Ctx->isFileContext()) return false; |

