summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-03-16 01:00:40 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-03-16 01:00:40 +0000
commitd292b24f9428e4527ace426fdc6cc3ea54b58cdf (patch)
treeea6612ffc7d0b987aed98cd31d92b330a228dd5b /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
parent049784ec504f2e3403ec4ed451b85347b5a07c23 (diff)
downloadbcm5719-llvm-d292b24f9428e4527ace426fdc6cc3ea54b58cdf.tar.gz
bcm5719-llvm-d292b24f9428e4527ace426fdc6cc3ea54b58cdf.zip
PR19152: If a variable template's type involves 'auto', instantiate the
initializer with the variable in order to determine the type. llvm-svn: 204015
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateDecl.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 5ea21ff14a2..8cfc4149e06 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3640,8 +3640,11 @@ void Sema::BuildVariableInstantiation(
Context.setStaticLocalNumber(NewVar, Context.getStaticLocalNumber(OldVar));
// Delay instantiation of the initializer for variable templates until a
- // definition of the variable is needed.
- if (!isa<VarTemplateSpecializationDecl>(NewVar) && !InstantiatingVarTemplate)
+ // definition of the variable is needed. We need it right away if the type
+ // contains 'auto'.
+ if ((!isa<VarTemplateSpecializationDecl>(NewVar) &&
+ !InstantiatingVarTemplate) ||
+ NewVar->getType()->isUndeducedType())
InstantiateVariableInitializer(NewVar, OldVar, TemplateArgs);
// Diagnose unused local variables with dependent types, where the diagnostic
OpenPOWER on IntegriCloud