[clang] [Clang][Sema] Mark partial specializations invalid when not more specialized than primary (PR #181561)
Giovanni B. via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 16 13:34:30 PST 2026
Z3rox-dev wrote:
@zwuis thanks for the follow-up, and good catch on the `stdget` making the whole program invalid regardless.
To clarify — the current revision of this PR is a Sema-only fix (no CodeGen changes). The diff is just two changes in `SemaTemplate.cpp`:
1. `checkMoreSpecializedThanPrimary()` emits the diagnostic but didn't call `setInvalidDecl()` — this adds it.
2. `ActOnClassTemplateSpecialization()` called `setInvalidDecl(Invalid)` where `Invalid` is `false` for partial specializations, clearing flags set by earlier checks — this changes it to only set the flag, never clear it.
This isn't hiding the problem — it's fixing a missing `setInvalidDecl()` call. The partial specialization *is* invalid (not more specialized than the primary), so marking it as such is the correct behavior and consistent with how other diagnostics in Sema work. The downstream deduction/instantiation infrastructure already skips invalid decls.
Your `template <auto>` variant is a different bug: the partial specialization there is valid, but `CXXUnresolvedConstructExpr` still survives instantiation. That's a deeper issue in template instantiation itself, tracked in #181062 and assigned to @mizvekov. This PR doesn't attempt to address it — only the crash path through invalid partial specializations (#181410).
https://github.com/llvm/llvm-project/pull/181561
More information about the cfe-commits
mailing list