================ @@ -6027,8 +6027,15 @@ void Sema::BuildVariableInstantiation( Context.setManglingNumber(NewVar, Context.getManglingNumber(OldVar)); Context.setStaticLocalNumber(NewVar, Context.getStaticLocalNumber(OldVar)); + bool VarTemplateWithAutoType = false; + QualType VarSourceType = OldVar->getTypeSourceInfo()->getType(); + if (VarSourceType->getAs<AutoType>()) { + VarTemplateWithAutoType = true; + } + // Figure out whether to eagerly instantiate the initializer. - if (InstantiatingVarTemplate || InstantiatingVarTemplatePartialSpec) { + if ((InstantiatingVarTemplate && !VarTemplateWithAutoType) || + InstantiatingVarTemplatePartialSpec) { // We're producing a template. Don't instantiate the initializer yet. } else if (NewVar->getType()->isUndeducedType()) { // We need the type to complete the declaration of the variable. ---------------- zwuis wrote:
It seems that we can just swap these two `if` statements. We need to handle partial specializations as well. E.g. ```cpp template <typename> struct B { template <typename, typrname> inline static auto var = 6; template <typename T> inline static auto var<int, T> = 7; }; int b = B<int>::var<int, int>; ``` https://github.com/llvm/llvm-project/pull/138122 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits