[clang] [Clang][Sema] Do not mark template parameters in the exception specification as used during partial ordering (PR #91534)
Krystian Stasiowski via cfe-commits
cfe-commits at lists.llvm.org
Wed May 8 14:39:09 PDT 2024
================
@@ -5485,20 +5485,40 @@ static bool isAtLeastAsSpecializedAs(Sema &S, SourceLocation Loc,
switch (TPOC) {
case TPOC_Call:
for (unsigned I = 0, N = Args2.size(); I != N; ++I)
- ::MarkUsedTemplateParameters(S.Context, Args2[I], false,
- TemplateParams->getDepth(),
- UsedParameters);
+ ::MarkUsedTemplateParameters(S.Context, Args2[I], /*OnlyDeduced=*/false,
+ TemplateParams->getDepth(), UsedParameters);
break;
case TPOC_Conversion:
- ::MarkUsedTemplateParameters(S.Context, Proto2->getReturnType(), false,
+ ::MarkUsedTemplateParameters(S.Context, Proto2->getReturnType(),
+ /*OnlyDeduced=*/false,
TemplateParams->getDepth(), UsedParameters);
break;
case TPOC_Other:
- ::MarkUsedTemplateParameters(S.Context, FD2->getType(), false,
- TemplateParams->getDepth(),
- UsedParameters);
+ // We do not deduce template arguments from the exception specification
+ // when determining the primary template of a function template
+ // specialization or when taking the address of a function template.
+ // Therefore, we do not mark template parameters in the exception
+ // specification as used during partial ordering to prevent the following
+ // from being ambiguous:
+ //
+ // template<typename T, typename U>
+ // void f(U) noexcept(noexcept(T())); // #1
+ //
+ // template<typename T>
+ // void f(T*) noexcept; // #2
+ //
+ // template<>
+ // void f<int>(int*) noexcept; // explicit specialization of #2
+ //
+ // Although there is no corresponding wording in the standard, this seems
----------------
sdkrystian wrote:
I'll open it tomorrow
https://github.com/llvm/llvm-project/pull/91534
More information about the cfe-commits
mailing list