================ @@ -4368,15 +4385,63 @@ Sema::CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, // Produce a placeholder value if the specialization is dependent. if (Template->getDeclContext()->isDependentContext() || TemplateSpecializationType::anyDependentTemplateArguments( - TemplateArgs, CTAI.CanonicalConverted)) + TemplateArgs, CTAI.CanonicalConverted)) { + if (ParsingInitForAutoVars.empty()) + return DeclResult(); + + if (VarDecl *Var = Template->getTemplatedDecl(); + ParsingInitForAutoVars.count(Var) && + llvm::equal( + CTAI.CanonicalConverted, + Template->getTemplateParameters()->getInjectedTemplateArgs(Context), + TemplateArgEqualityComparator{Context})) { + Diag(TemplateNameLoc, + diag::err_auto_variable_cannot_appear_in_own_initializer) + << diag::ParsingInitFor::VarTemplate << Var << Var->getType() + << SourceRange(TemplateNameLoc, TemplateArgs.getRAngleLoc()); ---------------- zyn0217 wrote:
I'm also wondering if it is necessary to draw underlines under the RHS of the declaration - would that be noisy if the declaration is too long? https://github.com/llvm/llvm-project/pull/134522 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits