Skip to content

Commit 5086c98

Browse files
committed
[Clang][Sema] Explicit template arguments are not substituted into the exception specification of a function
1 parent 7cbaaed commit 5086c98

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
@@ -3414,23 +3414,6 @@ TemplateDeductionResult Sema::SubstituteExplicitTemplateArguments(
34143414
if (FunctionType) {
34153415
auto EPI = Proto->getExtProtoInfo();
34163416
EPI.ExtParameterInfos = ExtParamInfos.getPointerOrNull(ParamTypes.size());
3417-
3418-
// In C++1z onwards, exception specifications are part of the function type,
3419-
// so substitution into the type must also substitute into the exception
3420-
// specification.
3421-
SmallVector<QualType, 4> ExceptionStorage;
3422-
if (getLangOpts().CPlusPlus17 &&
3423-
SubstExceptionSpec(
3424-
Function->getLocation(), EPI.ExceptionSpec, ExceptionStorage,
3425-
getTemplateInstantiationArgs(
3426-
FunctionTemplate, nullptr, /*Final=*/true,
3427-
/*Innermost=*/SugaredExplicitArgumentList->asArray(),
3428-
/*RelativeToPrimary=*/false,
3429-
/*Pattern=*/nullptr,
3430-
/*ForConstraintInstantiation=*/false,
3431-
/*SkipForSpecialization=*/true)))
3432-
return TemplateDeductionResult::SubstitutionFailure;
3433-
34343417
*FunctionType = BuildFunctionType(ResultType, ParamTypes,
34353418
Function->getLocation(),
34363419
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)