================ @@ -19849,11 +19849,14 @@ static void DoMarkVarDeclReferenced( SemaRef.InstantiateVariableDefinition(PointOfInstantiation, Var); }); - // Re-set the member to trigger a recomputation of the dependence bits - // for the expression. - if (auto *DRE = dyn_cast_or_null<DeclRefExpr>(E)) + if (auto *DRE = dyn_cast_or_null<DeclRefExpr>(E)) { + // Re-set the member to trigger a recomputation of the dependence bits + // for the expression. DRE->setDecl(DRE->getDecl()); - else if (auto *ME = dyn_cast_or_null<MemberExpr>(E)) + if (SemaRef.Context.getAsIncompleteArrayType(DRE->getType()) && + !SemaRef.Context.getAsIncompleteArrayType(Var->getType())) + DRE->setType(Var->getType()); + } else if (auto *ME = dyn_cast_or_null<MemberExpr>(E)) ---------------- zyn0217 wrote:
There are examples where the type of Var is a reference type that couldn't get bound to an expression ```cpp template<decltype(auto) v> void f() { } struct X {}; template<auto x> auto &TempParamObject = x; template void f<TempParamObject<X{}>>(); ``` The original type of DeclRefExpr is calculated by `BuildDeclarationNameExpr`, which is handled by a large switch-cases that I don't think it's reasonable to recompute the type through that logic at this point - It's rare (in fact, the IncompleteArray case is the only one I could think of) that substituting the initializer could change the type of the VarDecl - otherwise, we would have the type of Decl completed before the call to BuildDeclarationNameExpr(), which ensures the correctness of the DeclRefExpr. https://github.com/llvm/llvm-project/pull/133212 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits