diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-07-24 20:34:43 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-07-24 20:34:43 +0000 |
commit | 7caa6825f42a0f7e97d6fc06233133c42b218e46 (patch) | |
tree | 1be851e7cede92bb39bcb037c00a6d9a9061e946 /lib/Sema/SemaTemplateInstantiate.cpp | |
parent | 0eb7cff82f943ebcb14f1c9a2020a83a030a0893 (diff) |
Template instantiation for static data members that are defined out-of-line.
Note that this also fixes a bug that affects non-template code, where we
were not treating out-of-line static data members are "file-scope" variables,
and therefore not checking their initializers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77002 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index a75a8584d1..cb43f1c6a0 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -189,8 +189,7 @@ void Sema::PrintInstantiationStack() { DiagID) << Context.getTypeDeclType(Record) << Active->InstantiationRange; - } else { - FunctionDecl *Function = cast<FunctionDecl>(D); + } else if (FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) { unsigned DiagID; if (Function->getPrimaryTemplate()) DiagID = diag::note_function_template_spec_here; @@ -200,6 +199,11 @@ void Sema::PrintInstantiationStack() { DiagID) << Function << Active->InstantiationRange; + } else { + Diags.Report(FullSourceLoc(Active->PointOfInstantiation, SourceMgr), + diag::note_template_static_data_member_def_here) + << cast<VarDecl>(D) + << Active->InstantiationRange; } break; } @@ -1059,9 +1063,8 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation, if (!Function->getBody()) InstantiateFunctionDefinition(PointOfInstantiation, Function); } else if (VarDecl *Var = dyn_cast<VarDecl>(*D)) { - const VarDecl *Def = 0; - if (!Var->getDefinition(Def)) - InstantiateVariableDefinition(Var); + if (Var->isStaticDataMember()) + InstantiateStaticDataMemberDefinition(PointOfInstantiation, Var); } else if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(*D)) { if (!Record->isInjectedClassName() && !Record->getDefinition(Context)) { assert(Record->getInstantiatedFromMemberClass() && |