[clang] [clang] visit constraint of NTTP (PR #91842)
Krystian Stasiowski via cfe-commits
cfe-commits at lists.llvm.org
Thu May 16 08:05:42 PDT 2024
sdkrystian wrote:
I don't think this is the right approach. I stepped though the example and the reason we reject is because:
- We substitute a dependent `AutoType` in for the types of the template parameters when they are initially built.
- We call `getMoreSpecialized` determine whether the partial specialization is more specialized than the primary.
- We determine that neither template is at least as specialized as the other via `isAtLeastAsSpecializedAs`.
- We call `TemplateParameterListsAreEqual` per [[temp.func.order] p6.2.2](http://eel.is/c++draft/temp.func.order#6.2.2) to check for template parameter equivalence, and compare the two template parameters by calling `MatchTemplateParameterKind`.
- `MatchTemplateParameterKind` calls `ASTContext::getUnconstrainedType` to get the unconstrained type of the template parameters per [[temp.over.link] p6 sentence 2](http://eel.is/c++draft/temp.over.link#6.sentence-2). For class templates template parameter, it returns the type unchanged (a ***dependent*** `AutoType`). For the class template partial specializations template parameter, it returns an unconstrained `AutoType` ***that isn't dependent***.
- We compare the adjusted types and determine they aren't equal, so we consider neither template to be more specialized than the other.
So, I think the correct fix is to propagate dependence in `ASTContext::getUnconstrainedType`. I have a branch that implements this [here](https://github.com/sdkrystian/llvm-project/tree/partial-spec-dependent-auto). WDYT @erichkeane @cor3ntin?
https://github.com/llvm/llvm-project/pull/91842
More information about the cfe-commits
mailing list