[clang] [Clang] Allow explicit member specialization to differ from template declaration wrt constexpr (PR #145272)
Vikram Hegde via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 25 08:59:34 PDT 2025
================
@@ -12163,6 +12163,23 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
}
}
+ // C++11 [dcl.constexpr]p1: An explicit specialization of a constexpr
+ // function can differ from the template declaration with respect to
+ // the constexpr specifier.
+ if (IsMemberSpecialization) {
+ FunctionDecl *InstantiationFunction =
+ OldDecl ? OldDecl->getAsFunction() : nullptr;
+ if (InstantiationFunction &&
+ InstantiationFunction->getTemplateSpecializationKind() ==
+ TSK_ImplicitInstantiation &&
----------------
vikramRH wrote:
The old decl here is the member method of the classTemplateSpecializationDecl (implict instantiation of the template). would it be correct to mutate if old decl was any other kind (like explicit specialization decl) ? also I guess we cannot have a scenario where an old decl would directly be the primary template (i.e TemplateDecl) ?
https://github.com/llvm/llvm-project/pull/145272
More information about the cfe-commits
mailing list