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 | 3c7cd6a0c448bb5484f5f6c13cb0938d9e4d7768 (patch) | |
tree | d255d158d04a6e1bbf2b0dde7218da4b52316a72 /clang/lib/Sema/SemaDecl.cpp | |
parent | 4444daeec5650c75dbc3cfa9cf503a0ec27ebaf1 (diff) | |
download | bcm5719-llvm-3c7cd6a0c448bb5484f5f6c13cb0938d9e4d7768.tar.gz bcm5719-llvm-3c7cd6a0c448bb5484f5f6c13cb0938d9e4d7768.zip |
Specializations cannot be module-hidden. Diagnose attempts to do so.
llvm-svn: 139406
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 003be8289f6..355378eded7 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/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(); |