summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2016-11-02 15:46:34 +0000
committerAlex Lorenz <arphaman@gmail.com>2016-11-02 15:46:34 +0000
commit560ae565e9fa981ce2a49282b71c1e716ff347d1 (patch)
treee84aeceba2a821f6f863609ac9dd5307da27cb57 /clang/lib/Sema/SemaTemplate.cpp
parent93f2f7fb6c323083ec39abc0b67a9b51dc416684 (diff)
downloadbcm5719-llvm-560ae565e9fa981ce2a49282b71c1e716ff347d1.tar.gz
bcm5719-llvm-560ae565e9fa981ce2a49282b71c1e716ff347d1.zip
Add a note that points to the linkage specifier for the C++ linkage errors
This commit improves the "must have C++ linkage" error diagnostics that are emitted for C++ declarations like templates and literal operators by adding an additional note that points to the appropriate extern "C" linkage specifier. rdar://19021120 Differential Revision: https://reviews.llvm.org/D26189 llvm-svn: 285823
Diffstat (limited to 'clang/lib/Sema/SemaTemplate.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 71b2153d05a..ce41a5eb74f 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -5939,9 +5939,13 @@ Sema::CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams) {
// C++ [temp]p4:
// A template [...] shall not have C linkage.
DeclContext *Ctx = S->getEntity();
- if (Ctx && Ctx->isExternCContext())
- return Diag(TemplateParams->getTemplateLoc(), diag::err_template_linkage)
- << TemplateParams->getSourceRange();
+ if (Ctx && Ctx->isExternCContext()) {
+ Diag(TemplateParams->getTemplateLoc(), diag::err_template_linkage)
+ << TemplateParams->getSourceRange();
+ if (const LinkageSpecDecl *LSD = Ctx->getExternCContext())
+ Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
+ return true;
+ }
Ctx = Ctx->getRedeclContext();
// C++ [temp]p2:
OpenPOWER on IntegriCloud