diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 42 | ||||
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 9 |
3 files changed, 3 insertions, 50 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index c31850313a..ebcdcf58d0 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1456,12 +1456,6 @@ void Sema::MergeTypedefNameDecl(TypedefNameDecl *New, LookupResult &OldDecls) { if (TypedefNameDecl *Typedef = dyn_cast<TypedefNameDecl>(Old)) New->setPreviousDeclaration(Typedef); - // __module_private__ is propagated to later declarations. - if (Old->isModulePrivate()) - New->setModulePrivate(); - else if (New->isModulePrivate()) - diagnoseModulePrivateRedeclaration(New, Old); - if (getLangOptions().MicrosoftExt) return; @@ -2047,12 +2041,6 @@ bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old) { if (Old->isPure()) New->setPure(); - // __module_private__ is propagated to later declarations. - if (Old->isModulePrivate()) - New->setModulePrivate(); - else if (New->isModulePrivate()) - diagnoseModulePrivateRedeclaration(New, Old); - // Merge attributes from the parameters. These can mismatch with K&R // declarations. if (New->getNumParams() == Old->getNumParams()) @@ -2237,12 +2225,6 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) { return New->setInvalidDecl(); } - // __module_private__ is propagated to later declarations. - if (Old->isModulePrivate()) - New->setModulePrivate(); - else if (New->isModulePrivate()) - diagnoseModulePrivateRedeclaration(New, Old); - // Variables with external linkage are analyzed in FinalizeDeclaratorGroup. // FIXME: The test for external storage here seems wrong? We still @@ -5627,9 +5609,6 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, assert(OldTemplateDecl->isMemberSpecialization()); } - if (OldTemplateDecl->isModulePrivate()) - NewTemplateDecl->setModulePrivate(); - } else { if (isa<CXXMethodDecl>(NewFD)) // Set access for out-of-line definitions NewFD->setAccess(OldDecl->getAccess()); @@ -8212,19 +8191,14 @@ CreateNewDecl: AddMsStructLayoutForRecord(RD); } - if (PrevDecl && PrevDecl->isModulePrivate()) - New->setModulePrivate(); - else if (ModulePrivateLoc.isValid()) { + if (ModulePrivateLoc.isValid()) { if (isExplicitSpecialization) Diag(New->getLocation(), diag::err_module_private_specialization) << 2 << FixItHint::CreateRemoval(ModulePrivateLoc); - else if (PrevDecl && !PrevDecl->isModulePrivate()) - diagnoseModulePrivateRedeclaration(New, PrevDecl, ModulePrivateLoc); // __module_private__ does not apply to local classes. However, we only // diagnose this as an error when the declaration specifiers are // freestanding. Here, we just ignore the __module_private__. - // foobar else if (!SearchDC->isFunctionOrMethod()) New->setModulePrivate(); } @@ -9969,20 +9943,6 @@ DeclResult Sema::ActOnModuleImport(SourceLocation ImportLoc, ModuleIdPath Path) return Import; } -void -Sema::diagnoseModulePrivateRedeclaration(NamedDecl *New, NamedDecl *Old, - SourceLocation ModulePrivateKeyword) { - assert(!Old->isModulePrivate() && "Old is module-private!"); - - Diag(New->getLocation(), diag::err_module_private_follows_public) - << New->getDeclName() << SourceRange(ModulePrivateKeyword); - Diag(Old->getLocation(), diag::note_previous_declaration) - << Old->getDeclName(); - - // Drop the __module_private__ from the new declaration, since it's invalid. - New->setModulePrivate(false); -} - void Sema::ActOnPragmaWeakID(IdentifierInfo* Name, SourceLocation PragmaLoc, SourceLocation NameLoc) { diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index bc1cb3fca6..a5fc682d18 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -1169,7 +1169,7 @@ bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation) { // If this declaration is module-private and it came from an AST // file, we can't see it. - NamedDecl *D = getVisibleDecl(*I); + NamedDecl *D = R.isForRedeclaration()? *I : getVisibleDecl(*I); if (!D) continue; diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 8ec4c195f9..d0c0f0bf2d 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -1013,15 +1013,8 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, NewClass, PrevClassTemplate); NewClass->setDescribedClassTemplate(NewTemplate); - if (PrevClassTemplate && PrevClassTemplate->isModulePrivate()) { + if (ModulePrivateLoc.isValid()) NewTemplate->setModulePrivate(); - } else if (ModulePrivateLoc.isValid()) { - if (PrevClassTemplate && !PrevClassTemplate->isModulePrivate()) - diagnoseModulePrivateRedeclaration(NewTemplate, PrevClassTemplate, - ModulePrivateLoc); - else - NewTemplate->setModulePrivate(); - } // Build the type for the class template declaration now. QualType T = NewTemplate->getInjectedClassNameSpecialization(); |