[all-commits] [llvm/llvm-project] a0d266: [Clang][Sema] Allow elaborated-type-specifiers tha...
Krystian Stasiowski via All-commits
all-commits at lists.llvm.org
Tue Jan 30 05:28:25 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: a0d266d705d6c145e8daa08a08f70e9498ec3d0b
https://github.com/llvm/llvm-project/commit/a0d266d705d6c145e8daa08a08f70e9498ec3d0b
Author: Krystian Stasiowski <sdkrystian at gmail.com>
Date: 2024-01-30 (Tue, 30 Jan 2024)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/lib/Sema/SemaDecl.cpp
M clang/test/CXX/class.access/p4.cpp
A clang/test/CXX/dcl.dcl/dcl.enum/p1.cpp
M clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p1.cpp
M clang/test/CXX/drs/dr16xx.cpp
M clang/test/CXX/module/module.interface/p2-2.cpp
M clang/test/SemaCXX/enum-scoped.cpp
M clang/test/SemaCXX/nested-name-spec.cpp
M clang/test/SemaTemplate/elaborated-type-specifier.cpp
M clang/test/SemaTemplate/qualified-id.cpp
Log Message:
-----------
[Clang][Sema] Allow elaborated-type-specifiers that declare member class template explict specializations (#78720)
According to [[dcl.type.elab]
p2](http://eel.is/c++draft/dcl.type.elab#2):
> If an
[elaborated-type-specifier](http://eel.is/c++draft/dcl.type.elab#nt:elaborated-type-specifier)
is the sole constituent of a declaration, the declaration is ill-formed
unless it is an explicit specialization, an explicit instantiation or it
has one of the following forms [...]
Consider the following:
```cpp
template<typename T>
struct A
{
template<typename U>
struct B;
};
template<>
template<typename U>
struct A<int>::B; // #1
```
The _elaborated-type-specifier_ at `#1` declares an explicit
specialization (which is itself a template). We currently (incorrectly)
reject this, and this PR fixes that.
I moved the point at which _elaborated-type-specifiers_ with
_nested-name-specifiers_ are diagnosed from `ParsedFreeStandingDeclSpec`
to `ActOnTag` for two reasons: `ActOnTag` isn't called for explicit
instantiations and partial/explicit specializations, and because it's
where we determine if a member specialization is being declared.
With respect to diagnostics, I am currently issuing the diagnostic
without marking the declaration as invalid or returning early, which
results in more diagnostics that I think is necessary. I would like
feedback regarding what the "correct" behavior should be here.
More information about the All-commits
mailing list