diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-09-09 20:53:38 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-09-09 20:53:38 +0000 |
commit | d023aec8907831a18d3514a95b843a7ee06b6b5e (patch) | |
tree | 4ca632e18dc3b46d86ed30410cc49728473ef27a /lib/Sema/SemaDecl.cpp | |
parent | 13db5cfc4e5f03eb70efe0d227b53b8280f16161 (diff) |
Specializations cannot be module-hidden. Diagnose attempts to do so.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139406 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 003be8289f..355378eded 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3821,8 +3821,14 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, NewVD->setThreadSpecified(true); } - if (D.getDeclSpec().isModulePrivateSpecified()) - NewVD->setModulePrivate(); + if (D.getDeclSpec().isModulePrivateSpecified()) { + if (isExplicitSpecialization) + Diag(NewVD->getLocation(), diag::err_module_private_specialization) + << 2 + << FixItHint::CreateRemoval(D.getDeclSpec().getModulePrivateSpecLoc()); + else + NewVD->setModulePrivate(); + } // Set the lexical context. If the declarator has a C++ scope specifier, the // lexical context will be different from the semantic context. @@ -4709,9 +4715,17 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // If __module_private__ was specified, mark the function accordingly. if (D.getDeclSpec().isModulePrivateSpecified()) { - NewFD->setModulePrivate(); - if (FunctionTemplate) - FunctionTemplate->setModulePrivate(); + if (isFunctionTemplateSpecialization) { + SourceLocation ModulePrivateLoc + = D.getDeclSpec().getModulePrivateSpecLoc(); + Diag(ModulePrivateLoc, diag::err_module_private_specialization) + << 0 + << FixItHint::CreateRemoval(ModulePrivateLoc); + } else { + NewFD->setModulePrivate(); + if (FunctionTemplate) + FunctionTemplate->setModulePrivate(); + } } // Filter out previous declarations that don't match the scope. @@ -7751,7 +7765,11 @@ CreateNewDecl: if (PrevDecl && PrevDecl->isModulePrivate()) New->setModulePrivate(); else if (ModulePrivateLoc.isValid()) { - if (PrevDecl && !PrevDecl->isModulePrivate()) + if (isExplicitSpecialization) + Diag(New->getLocation(), diag::err_module_private_specialization) + << 2 + << FixItHint::CreateRemoval(ModulePrivateLoc); + else if (PrevDecl && !PrevDecl->isModulePrivate()) diagnoseModulePrivateRedeclaration(New, PrevDecl, ModulePrivateLoc); else New->setModulePrivate(); |