https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/196919
This is missed when we implemented CWG2369, where their instantiations should be built in place when they are needed. Fixes #173086 >From 5c7732e113abe97f8d9b0c675bec80669b35abaf Mon Sep 17 00:00:00 2001 From: Younan Zhang <[email protected]> Date: Mon, 11 May 2026 18:20:07 +0800 Subject: [PATCH] [Clang] Instantiate ParmVarDecls on-demand for FunctionParmPackExpr This is missed when we implemented CWG2369, where their instantiations should be built in place when they are needed. --- clang/docs/ReleaseNotes.rst | 1 + clang/lib/Sema/SemaTemplateInstantiate.cpp | 10 +++++++++- clang/test/SemaTemplate/concepts.cpp | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index fd58d7847717c..fbe4b2787ce87 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -407,6 +407,7 @@ Bug Fixes in This Version - Fixed the behavior in C23 of ``auto``, by emitting an error when an array type is specified for a ``char *``. (#GH162694) - Fixed incorrect rejection of ``auto`` with reordered declaration specifiers in C23. (#GH164121) - Fixed a crash where constexpr evaluation encountered invalid overrides. (#GH183290) +- Fixed a bug where Clang fails to find instantiation of Decls in constraint checking. (#GH173086) - Fixed a crash when assigning to an element of an ``ext_vector_type`` with ``bool`` element type. (#GH189260) Bug Fixes to Compiler Builtins diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 8dfe33f8684bd..3ab363bff2feb 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -2399,8 +2399,16 @@ TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) { // Handle references to function parameter packs. if (VarDecl *PD = dyn_cast<VarDecl>(D)) - if (PD->isParameterPack()) + if (PD->isParameterPack()) { + if (ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(PD); + PVD && SemaRef.CurrentInstantiationScope && + (SemaRef.inConstraintSubstitution() || + SemaRef.inParameterMappingSubstitution()) && + maybeInstantiateFunctionParameterToScope(PVD)) + return ExprError(); + return TransformFunctionParmPackRefExpr(E, PD); + } return inherited::TransformDeclRefExpr(E); } diff --git a/clang/test/SemaTemplate/concepts.cpp b/clang/test/SemaTemplate/concepts.cpp index ac80d16b4ccf8..4f72f650f8cbc 100644 --- a/clang/test/SemaTemplate/concepts.cpp +++ b/clang/test/SemaTemplate/concepts.cpp @@ -1250,6 +1250,22 @@ int i = SVGPropertyOwnerRegistry<SVGCircleElement>::fastAnimatedPropertyLookup() } +namespace GH173086 { + +template <typename, unsigned, typename> struct GeneralTensor {}; +template <typename T, unsigned Rank> using Tensor = GeneralTensor<T, Rank, int>; +template <typename T, unsigned OtherRank, typename Alloc, typename... Dims> +GeneralTensor(GeneralTensor<T, OtherRank, Alloc>, Dims... dims) + -> GeneralTensor<T, sizeof...(dims), Alloc>; +template <typename... MultiIndex> +Tensor<double, sizeof...(MultiIndex)> create_incremented_tensor() { + return Tensor<double, sizeof...(MultiIndex)>(); +} + +auto x = Tensor{create_incremented_tensor<>()}; + +} + namespace GH61824 { template<typename T, typename U = typename T::type> // #T_Type _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
