diff options
author | Vassil Vassilev <v.g.vassilev@gmail.com> | 2016-10-11 13:57:36 +0000 |
---|---|---|
committer | Vassil Vassilev <v.g.vassilev@gmail.com> | 2016-10-11 13:57:36 +0000 |
commit | 4b3e7388d1a90f3e20a90d5624fe54dccca2610f (patch) | |
tree | e0456da083480b6cfbeb8876c417f63657291aed /clang/lib/Sema/SemaDecl.cpp | |
parent | 092cfc597f11a8544c6a9616bbae3e1f727838e0 (diff) | |
download | bcm5719-llvm-4b3e7388d1a90f3e20a90d5624fe54dccca2610f.tar.gz bcm5719-llvm-4b3e7388d1a90f3e20a90d5624fe54dccca2610f.zip |
[modules] PR28752: Do not instantiate variable declarations which are not visible.
https://reviews.llvm.org/D24508
Patch developed in collaboration with Richard Smith!
llvm-svn: 283882
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 7baa85a6464..c9a45b2ecc5 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -9708,6 +9708,21 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, VDecl->getDeclContext()->isDependentContext())) { // The previous definition is hidden, and multiple definitions are // permitted (in separate TUs). Form another definition of it. + + // Demote the newly parsed definition to a fake declaration. + if (!VDecl->isThisDeclarationADemotedDefinition()) + VDecl->demoteThisDefinitionToDeclaration(); + + // Make the definition visible from the point of the demotion on. + assert (!Hidden || Def == Hidden && + "We were suggested another hidden definition!"); + makeMergedDefinitionVisible(Def, VDecl->getLocation()); + + // If this is a variable template definition, make its enclosing template + // visible. + if (VarDecl *VarPattern = Def->getTemplateInstantiationPattern()) + if (VarPattern->isThisDeclarationADefinition()) + makeMergedDefinitionVisible(VarPattern, VDecl->getLocation()); } else { Diag(VDecl->getLocation(), diag::err_redefinition) << VDecl->getDeclName(); |