Per CWG727, class scope declarations of explicit specializations of function templates are valid. Within class templates, such declarations are currently handled by creating a ClassScopeFunctionSpecializationDecl
AST node, which defers lookup of the primary template until the declaration is instantiated. This is a hack, and results in some pretty obviously invalid constructs not being diagnosed until instantiation. For example:
template<typename T>
struct A
{
template<> void f();
};
If instead we use DependentFunctionTemplateSpecializationInfo
, we can eliminate the ClassScopeFunctionSpecializationDecl
AST node, and diagnose such constructs prior to instantiation. I have a branch with this implemented (some cleanups are still required).
Is there anything I’m missing here? Any reasons why such a change shouldn’t/couldn’t be made? Any feedback is appreciated