summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-10-12 23:29:02 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-10-12 23:29:02 +0000
commit88d10b68e0975510477d87e585c020a929739778 (patch)
treec56bd85a61a3b1e1dca2ba7cf5cda6882d290f55 /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
parentd9fa56a4fb24c4763adf2ea4e16b04a4f43e3e08 (diff)
downloadbcm5719-llvm-88d10b68e0975510477d87e585c020a929739778.tar.gz
bcm5719-llvm-88d10b68e0975510477d87e585c020a929739778.zip
Revert r284008. This is us to fail to instantiate static data members in some
cases. I'm working on reducing a testcase. llvm-svn: 284081
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateDecl.cpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 911bc512c87..09068d71ffb 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4068,10 +4068,6 @@ void Sema::InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
PrettyDeclStackTraceEntry CrashInfo(*this, Var, SourceLocation(),
"instantiating variable initializer");
- // The instantiation is visible here, even if it was first declared in an
- // unimported module.
- Var->setHidden(false);
-
// If we're performing recursive template instantiation, create our own
// queue of pending implicit instantiations that we will instantiate
// later, while we're still within our own instantiation context.
@@ -4120,17 +4116,33 @@ void Sema::InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
Def = PatternDecl->getDefinition();
}
- TemplateSpecializationKind TSK = Var->getTemplateSpecializationKind();
+ // FIXME: Check that the definition is visible before trying to instantiate
+ // it. This requires us to track the instantiation stack in order to know
+ // which definitions should be visible.
// If we don't have a definition of the variable template, we won't perform
// any instantiation. Rather, we rely on the user to instantiate this
// definition (or provide a specialization for it) in another translation
// unit.
- if (!Def && !DefinitionRequired) {
- if (TSK == TSK_ExplicitInstantiationDefinition) {
+ if (!Def) {
+ if (DefinitionRequired) {
+ if (VarSpec) {
+ Diag(PointOfInstantiation,
+ diag::err_explicit_instantiation_undefined_var_template) << Var;
+ Var->setInvalidDecl();
+ }
+ else
+ Diag(PointOfInstantiation,
+ diag::err_explicit_instantiation_undefined_member)
+ << 2 << Var->getDeclName() << Var->getDeclContext();
+ Diag(PatternDecl->getLocation(),
+ diag::note_explicit_instantiation_here);
+ } else if (Var->getTemplateSpecializationKind()
+ == TSK_ExplicitInstantiationDefinition) {
PendingInstantiations.push_back(
std::make_pair(Var, PointOfInstantiation));
- } else if (TSK == TSK_ImplicitInstantiation) {
+ } else if (Var->getTemplateSpecializationKind()
+ == TSK_ImplicitInstantiation) {
// Warn about missing definition at the end of translation unit.
if (AtEndOfTU && !getDiagnostics().hasErrorOccurred()) {
Diag(PointOfInstantiation, diag::warn_var_template_missing)
@@ -4139,20 +4151,12 @@ void Sema::InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
if (getLangOpts().CPlusPlus11)
Diag(PointOfInstantiation, diag::note_inst_declaration_hint) << Var;
}
- return;
}
- }
-
- // FIXME: We need to track the instantiation stack in order to know which
- // definitions should be visible within this instantiation.
- // FIXME: Produce diagnostics when Var->getInstantiatedFromStaticDataMember().
- if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Var,
- /*InstantiatedFromMember*/false,
- PatternDecl, Def, TSK,
- /*Complain*/DefinitionRequired))
return;
+ }
+ TemplateSpecializationKind TSK = Var->getTemplateSpecializationKind();
// Never instantiate an explicit specialization.
if (TSK == TSK_ExplicitSpecialization)
OpenPOWER on IntegriCloud