Skip to content

Commit ff5dfd4

Browse files
committed
[Sema] Avoid attaching 'noreturn' attribute to explicit function template specializations
1 parent 4d48996 commit ff5dfd4

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3267,6 +3267,14 @@ void Sema::mergeDeclAttributes(NamedDecl *New, Decl *Old,
32673267
if (isa<UsedAttr>(I) || isa<RetainAttr>(I))
32683268
continue;
32693269

3270+
if (isa<InferredNoReturnAttr>(I)) {
3271+
if (auto *FD = dyn_cast<FunctionDecl>(New)) {
3272+
if (FD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
3273+
continue; // Don't propagate inferred noreturn attributes to explicit
3274+
// specializations.
3275+
}
3276+
}
3277+
32703278
if (mergeDeclAttribute(*this, New, I, LocalAMK))
32713279
foundAny = true;
32723280
}

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,6 +1970,9 @@ void clang::inferNoReturnAttr(Sema &S, const Decl *D) {
19701970
if (!FD)
19711971
return;
19721972

1973+
if (FD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
1974+
return; // Don't infer noreturn for explicit specializations.
1975+
19731976
auto *NonConstFD = const_cast<FunctionDecl *>(FD);
19741977
DiagnosticsEngine &Diags = S.getDiagnostics();
19751978
if (Diags.isIgnored(diag::warn_falloff_nonvoid, FD->getLocation()) &&

0 commit comments

Comments
 (0)