Skip to content

Commit a30530b

Browse files
committed
[Clang][Sema] Explicit template arguments are not substituted into the exception specification of a function
1 parent 8e7618a commit a30530b

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

clang/lib/Sema/SemaTemplateDeduction.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3509,23 +3509,6 @@ TemplateDeductionResult Sema::SubstituteExplicitTemplateArguments(
35093509
if (FunctionType) {
35103510
auto EPI = Proto->getExtProtoInfo();
35113511
EPI.ExtParameterInfos = ExtParamInfos.getPointerOrNull(ParamTypes.size());
3512-
3513-
// In C++1z onwards, exception specifications are part of the function type,
3514-
// so substitution into the type must also substitute into the exception
3515-
// specification.
3516-
SmallVector<QualType, 4> ExceptionStorage;
3517-
if (getLangOpts().CPlusPlus17 &&
3518-
SubstExceptionSpec(
3519-
Function->getLocation(), EPI.ExceptionSpec, ExceptionStorage,
3520-
getTemplateInstantiationArgs(
3521-
FunctionTemplate, nullptr, /*Final=*/true,
3522-
/*Innermost=*/SugaredExplicitArgumentList->asArray(),
3523-
/*RelativeToPrimary=*/false,
3524-
/*Pattern=*/nullptr,
3525-
/*ForConstraintInstantiation=*/false,
3526-
/*SkipForSpecialization=*/true)))
3527-
return TemplateDeductionResult::SubstitutionFailure;
3528-
35293512
*FunctionType = BuildFunctionType(ResultType, ParamTypes,
35303513
Function->getLocation(),
35313514
Function->getDeclName(),
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %clang_cc1 -verify %s
2+
3+
struct A {
4+
static constexpr bool x = true;
5+
};
6+
7+
template<typename T, typename U>
8+
void f(T, U) noexcept(T::x);
9+
10+
template<typename T, typename U>
11+
void f(T, U*) noexcept(T::y); // expected-error {{no member named 'y' in 'A'}}
12+
13+
template<>
14+
void f<A>(A, int*); // expected-note {{in instantiation of exception specification}}

0 commit comments

Comments
 (0)