summaryrefslogtreecommitdiffstats
path: root/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
commitc5d060f4fad38c242f579e42a0f596702b0ccfbd (patch)
tree6ef9a52a1756008baeeaca9fa79e3f43a9bd3e88 /lib/Sema/SemaTemplateInstantiateDecl.cpp
parentb746d24a20dd3dd173c72f2365b1307e9e355436 (diff)
PR19152: If a variable template's type involves 'auto', instantiate the
initializer with the variable in order to determine the type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204015 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 5ea21ff14a..8cfc4149e0 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/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