https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/191154
>From e05e87da59ac0cce0d9590fc006f362ed3136f5b Mon Sep 17 00:00:00 2001 From: Corentin Jabot <[email protected]> Date: Thu, 9 Apr 2026 12:10:42 +0200 Subject: [PATCH 1/3] [Clang] Fix handling of references to variable templates with an empty argument list In some cases they were treated as having no argument list at all. Fixes #191016. --- clang/docs/ReleaseNotes.rst | 1 + clang/include/clang/AST/ExprCXX.h | 8 +++++--- clang/test/SemaTemplate/concepts.cpp | 11 +++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 2da7175b51ea3..a72821bf970f1 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -426,6 +426,7 @@ Bug Fixes to C++ Support template parameters when one of its parameters is also a pack. (#GH181166) - Fixed a crash when a default argument is passed to an explicit object parameter. (#GH176639) - Fixed an alias template CTAD crash. +- Fix handling of ``Var<>`` when refering to a static member variable template. (#GH191016) - Fixed a crash when diagnosing an invalid static member function with an explicit object parameter (#GH177741) - Fixed a crash when instantiating an invalid out-of-line static data member definition in a local class. (#GH176152) - Fixed a crash when pack expansions are used as arguments for non-pack parameters of built-in templates. (#GH180307) diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index c40cd929b7408..10c0f2ba6c44b 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -3281,12 +3281,14 @@ class OverloadExpr : public Expr { bool hasExplicitTemplateArgs() const { if (!hasTemplateKWAndArgsInfo()) return false; + if (getLAngleLoc().isValid()) + return true; // FIXME: deduced function types can have "hidden" args and no < // investigate that further, but ultimately maybe we want to model concepts // reference with another kind of expression. - return (isConceptReference() || isVarDeclReference()) - ? getTrailingASTTemplateKWAndArgsInfo()->NumTemplateArgs - : getLAngleLoc().isValid(); + if (isConceptReference() || isVarDeclReference()) + return getTrailingASTTemplateKWAndArgsInfo()->NumTemplateArgs; + return false; } bool isConceptReference() const { diff --git a/clang/test/SemaTemplate/concepts.cpp b/clang/test/SemaTemplate/concepts.cpp index 429df756c1c4f..ac80d16b4ccf8 100644 --- a/clang/test/SemaTemplate/concepts.cpp +++ b/clang/test/SemaTemplate/concepts.cpp @@ -1824,3 +1824,14 @@ namespace GH176402 { recursiveLambda(recursiveLambda, 5); } } +namespace GH191016 { + template <typename T = int> + struct S { + template <typename Args = int> + constexpr static bool P = true; + template <typename... Args> + constexpr static bool Q = true; + S() requires P<> && Q<> {} + }; + void test(){ S<int> s; } +} >From a7df3c347d863e097713e1ac9d3b796381b4546b Mon Sep 17 00:00:00 2001 From: Corentin Jabot <[email protected]> Date: Thu, 9 Apr 2026 13:41:46 +0200 Subject: [PATCH 2/3] remove stale comment --- clang/include/clang/AST/ExprCXX.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 10c0f2ba6c44b..948f18b31a5fc 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -3279,16 +3279,10 @@ class OverloadExpr : public Expr { /// Determines whether this expression had explicit template arguments. bool hasExplicitTemplateArgs() const { - if (!hasTemplateKWAndArgsInfo()) - return false; if (getLAngleLoc().isValid()) return true; - // FIXME: deduced function types can have "hidden" args and no < - // investigate that further, but ultimately maybe we want to model concepts - // reference with another kind of expression. - if (isConceptReference() || isVarDeclReference()) - return getTrailingASTTemplateKWAndArgsInfo()->NumTemplateArgs; - return false; + return hasTemplateKWAndArgsInfo() && + getTrailingASTTemplateKWAndArgsInfo()->NumTemplateArgs; } bool isConceptReference() const { >From 8ccca6a87164b89ef7934ccb53b32a1bad5b6415 Mon Sep 17 00:00:00 2001 From: Corentin Jabot <[email protected]> Date: Thu, 9 Apr 2026 14:46:25 +0200 Subject: [PATCH 3/3] remove release note --- clang/docs/ReleaseNotes.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index a72821bf970f1..2da7175b51ea3 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -426,7 +426,6 @@ Bug Fixes to C++ Support template parameters when one of its parameters is also a pack. (#GH181166) - Fixed a crash when a default argument is passed to an explicit object parameter. (#GH176639) - Fixed an alias template CTAD crash. -- Fix handling of ``Var<>`` when refering to a static member variable template. (#GH191016) - Fixed a crash when diagnosing an invalid static member function with an explicit object parameter (#GH177741) - Fixed a crash when instantiating an invalid out-of-line static data member definition in a local class. (#GH176152) - Fixed a crash when pack expansions are used as arguments for non-pack parameters of built-in templates. (#GH180307) _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
