[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/sdkrystian closed https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/88042 >From e850ae0982efbb7cec7c33d6b927844d89128743 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Mon, 8 Apr 2024 09:46:08 -0400 Subject: [PATCH 1/5] [Clang][Sema] Implement approved resolution for CWG2858 --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 7 +++ clang/lib/Sema/SemaDecl.cpp | 13 ++--- .../expr.prim.id/expr.prim.id.qual/p3.cpp| 16 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4fbbc42273ba93..2ce2013aac7362 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2402,10 +2402,6 @@ def err_selected_explicit_constructor : Error< def note_explicit_ctor_deduction_guide_here : Note< "explicit %select{constructor|deduction guide}0 declared here">; -// C++11 decltype -def err_decltype_in_declarator : Error< -"'decltype' cannot be used to name a declaration">; - // C++11 auto def warn_cxx98_compat_auto_type_specifier : Warning< "'auto' type specifier is incompatible with C++98">, @@ -8302,6 +8298,9 @@ def ext_template_after_declarative_nns : ExtWarn< def ext_alias_template_in_declarative_nns : ExtWarn< "a declarative nested name specifier cannot name an alias template">, InGroup>; +def err_computed_type_in_declarative_nns : Error< + "%select{a pack indexing type|'decltype'}0 cannot be used in " + "a declarative nested name specifier">; def err_no_typeid_with_fno_rtti : Error< "use of typeid requires -frtti">; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c790dab72dd721..1ba6b3beb1c758 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6335,16 +6335,15 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec , DeclContext *DC, if (TST->isDependentType() && TST->isTypeAlias()) Diag(Loc, diag::ext_alias_template_in_declarative_nns) << SpecLoc.getLocalSourceRange(); - } else if (T->isDecltypeType()) { + } else if (T->isDecltypeType() || T->getAsAdjusted()) { // C++23 [expr.prim.id.qual]p2: // [...] A declarative nested-name-specifier shall not have a -// decltype-specifier. +// computed-type-specifier. // -// FIXME: This wording appears to be defective as it does not forbid -// declarative nested-name-specifiers with pack-index-specifiers. -// See https://github.com/cplusplus/CWG/issues/499. -Diag(Loc, diag::err_decltype_in_declarator) -<< SpecLoc.getTypeLoc().getSourceRange(); +// CWG2858 changed this from 'decltype-specifier' to +// 'computed-type-specifier'. +Diag(Loc, diag::err_computed_type_in_declarative_nns) +<< T->isDecltypeType() << SpecLoc.getTypeLoc().getSourceRange(); } } } while ((SpecLoc = SpecLoc.getPrefix())); diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp index c73ffa55a26a31..5da13cc22abef2 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -std=c++2c -verify %s template struct A { @@ -27,3 +28,18 @@ namespace N { template void N::E::f() { } // expected-warning {{a declarative nested name specifier cannot name an alias template}} + +#if __cplusplus > 202302L +template +struct A { + // FIXME: The nested-name-specifier in the following friend declarations are declarative, + // but we don't treat them as such (yet). + friend void Ts...[0]::f(); + template + friend void Ts...[0]::g(); + + friend struct Ts...[0]::B; + template + friend struct Ts...[0]::C; // expected-warning{{is not supported; ignoring this friend declaration}} +}; +#endif >From e0646d2098f567ca0cd5642c8694d3d8980134c7 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Tue, 9 Apr 2024 09:03:25 -0400 Subject: [PATCH 2/5] [FOLD] apply review changes --- clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp | 4 ++-- clang/test/CXX/drs/dr28xx.cpp | 21 +++ .../expr.prim.id/expr.prim.id.qual/p3.cpp | 16 -- clang/test/Parser/cxx-class.cpp | 6 +++--- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp index fbe9c0895aeae8..3e67fca9ad7376 100644 --- a/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp +++ b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp @@ -6,8 +6,8 @@ class foo { void func(); }; -int decltype(foo())::i; //
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
Endilll wrote: Please do. This is going to be reverted by the next person fetching from public index page anyway, because we ask people to run the script every time they have changes for `cxx_dr_status.html`. In any case, WG21 wikis are of restricted access, and we shouldn't make their content public like this. https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
sdkrystian wrote: @Endilll I ran `make_cxx_dr_status` with the index from the WG21 wiki... should I drop the commit? https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
Endilll wrote: `make_cxx_dr_status` is not going to do anything here, since the DR indeed didn't make it into public list. Merge as-is. 2858 is going to be picked up when someone runs the script for the first time after a new revision of core issues list is published. https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/88042 >From e850ae0982efbb7cec7c33d6b927844d89128743 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Mon, 8 Apr 2024 09:46:08 -0400 Subject: [PATCH 1/6] [Clang][Sema] Implement approved resolution for CWG2858 --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 7 +++ clang/lib/Sema/SemaDecl.cpp | 13 ++--- .../expr.prim.id/expr.prim.id.qual/p3.cpp| 16 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4fbbc42273ba93..2ce2013aac7362 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2402,10 +2402,6 @@ def err_selected_explicit_constructor : Error< def note_explicit_ctor_deduction_guide_here : Note< "explicit %select{constructor|deduction guide}0 declared here">; -// C++11 decltype -def err_decltype_in_declarator : Error< -"'decltype' cannot be used to name a declaration">; - // C++11 auto def warn_cxx98_compat_auto_type_specifier : Warning< "'auto' type specifier is incompatible with C++98">, @@ -8302,6 +8298,9 @@ def ext_template_after_declarative_nns : ExtWarn< def ext_alias_template_in_declarative_nns : ExtWarn< "a declarative nested name specifier cannot name an alias template">, InGroup>; +def err_computed_type_in_declarative_nns : Error< + "%select{a pack indexing type|'decltype'}0 cannot be used in " + "a declarative nested name specifier">; def err_no_typeid_with_fno_rtti : Error< "use of typeid requires -frtti">; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c790dab72dd721..1ba6b3beb1c758 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6335,16 +6335,15 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec , DeclContext *DC, if (TST->isDependentType() && TST->isTypeAlias()) Diag(Loc, diag::ext_alias_template_in_declarative_nns) << SpecLoc.getLocalSourceRange(); - } else if (T->isDecltypeType()) { + } else if (T->isDecltypeType() || T->getAsAdjusted()) { // C++23 [expr.prim.id.qual]p2: // [...] A declarative nested-name-specifier shall not have a -// decltype-specifier. +// computed-type-specifier. // -// FIXME: This wording appears to be defective as it does not forbid -// declarative nested-name-specifiers with pack-index-specifiers. -// See https://github.com/cplusplus/CWG/issues/499. -Diag(Loc, diag::err_decltype_in_declarator) -<< SpecLoc.getTypeLoc().getSourceRange(); +// CWG2858 changed this from 'decltype-specifier' to +// 'computed-type-specifier'. +Diag(Loc, diag::err_computed_type_in_declarative_nns) +<< T->isDecltypeType() << SpecLoc.getTypeLoc().getSourceRange(); } } } while ((SpecLoc = SpecLoc.getPrefix())); diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp index c73ffa55a26a31..5da13cc22abef2 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -std=c++2c -verify %s template struct A { @@ -27,3 +28,18 @@ namespace N { template void N::E::f() { } // expected-warning {{a declarative nested name specifier cannot name an alias template}} + +#if __cplusplus > 202302L +template +struct A { + // FIXME: The nested-name-specifier in the following friend declarations are declarative, + // but we don't treat them as such (yet). + friend void Ts...[0]::f(); + template + friend void Ts...[0]::g(); + + friend struct Ts...[0]::B; + template + friend struct Ts...[0]::C; // expected-warning{{is not supported; ignoring this friend declaration}} +}; +#endif >From e0646d2098f567ca0cd5642c8694d3d8980134c7 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Tue, 9 Apr 2024 09:03:25 -0400 Subject: [PATCH 2/6] [FOLD] apply review changes --- clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp | 4 ++-- clang/test/CXX/drs/dr28xx.cpp | 21 +++ .../expr.prim.id/expr.prim.id.qual/p3.cpp | 16 -- clang/test/Parser/cxx-class.cpp | 6 +++--- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp index fbe9c0895aeae8..3e67fca9ad7376 100644 --- a/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp +++ b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp @@ -6,8 +6,8 @@ class foo { void func(); }; -int decltype(foo())::i; //
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/erichkeane approved this pull request. @endilll says 'Good to go' with the dr-status updated, so I'll approve. https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
sdkrystian wrote: Oh, sorry. I'll do that :) https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
erichkeane wrote: > Could also get them from the CWG GitHub pages repository > (https://github.com/cplusplus/CWG/tree/gh-pages/issues)... anyways, am I good > to merge this? I believe we would still like you to re-generate with : www/make_cxx_dr_status https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
sdkrystian wrote: Could also get them from the CWG GitHub pages repository (https://github.com/cplusplus/CWG/tree/gh-pages/issues)... anyways, am I good to merge this? https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
erichkeane wrote: > @Endilll `clang/www/make_cxx_dr_status` queries core issues from > https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_index.html. Since a new > revision of the index has not yet been published since CWG2858 was opened, > `clang/www/make_cxx_dr_status` doesn't add an entry for the issue. Yeah, those don't get published consistently. You have to pick them up from the latest committee wiki (see the 'attachments' list here: https://wiki.edg.com/bin/view/Wg21tokyo2024/CoreWorkingGroup). https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
sdkrystian wrote: @Endilll `clang/www/make_cxx_dr_status` queries core issues from https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_index.html. Since a new revision of the index has not yet been published since CWG2858 was opened, `clang/www/make_cxx_dr_status` doesn't add an entry for the issue. https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/Endilll commented: This looks much better now, thank you! As Corentin suggested earlier, run `clang/www/make_cxx_dr_status` to update the DR page, and this should be good to go. https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/88042 >From e850ae0982efbb7cec7c33d6b927844d89128743 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Mon, 8 Apr 2024 09:46:08 -0400 Subject: [PATCH 1/5] [Clang][Sema] Implement approved resolution for CWG2858 --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 7 +++ clang/lib/Sema/SemaDecl.cpp | 13 ++--- .../expr.prim.id/expr.prim.id.qual/p3.cpp| 16 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4fbbc42273ba93..2ce2013aac7362 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2402,10 +2402,6 @@ def err_selected_explicit_constructor : Error< def note_explicit_ctor_deduction_guide_here : Note< "explicit %select{constructor|deduction guide}0 declared here">; -// C++11 decltype -def err_decltype_in_declarator : Error< -"'decltype' cannot be used to name a declaration">; - // C++11 auto def warn_cxx98_compat_auto_type_specifier : Warning< "'auto' type specifier is incompatible with C++98">, @@ -8302,6 +8298,9 @@ def ext_template_after_declarative_nns : ExtWarn< def ext_alias_template_in_declarative_nns : ExtWarn< "a declarative nested name specifier cannot name an alias template">, InGroup>; +def err_computed_type_in_declarative_nns : Error< + "%select{a pack indexing type|'decltype'}0 cannot be used in " + "a declarative nested name specifier">; def err_no_typeid_with_fno_rtti : Error< "use of typeid requires -frtti">; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c790dab72dd721..1ba6b3beb1c758 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6335,16 +6335,15 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec , DeclContext *DC, if (TST->isDependentType() && TST->isTypeAlias()) Diag(Loc, diag::ext_alias_template_in_declarative_nns) << SpecLoc.getLocalSourceRange(); - } else if (T->isDecltypeType()) { + } else if (T->isDecltypeType() || T->getAsAdjusted()) { // C++23 [expr.prim.id.qual]p2: // [...] A declarative nested-name-specifier shall not have a -// decltype-specifier. +// computed-type-specifier. // -// FIXME: This wording appears to be defective as it does not forbid -// declarative nested-name-specifiers with pack-index-specifiers. -// See https://github.com/cplusplus/CWG/issues/499. -Diag(Loc, diag::err_decltype_in_declarator) -<< SpecLoc.getTypeLoc().getSourceRange(); +// CWG2858 changed this from 'decltype-specifier' to +// 'computed-type-specifier'. +Diag(Loc, diag::err_computed_type_in_declarative_nns) +<< T->isDecltypeType() << SpecLoc.getTypeLoc().getSourceRange(); } } } while ((SpecLoc = SpecLoc.getPrefix())); diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp index c73ffa55a26a31..5da13cc22abef2 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -std=c++2c -verify %s template struct A { @@ -27,3 +28,18 @@ namespace N { template void N::E::f() { } // expected-warning {{a declarative nested name specifier cannot name an alias template}} + +#if __cplusplus > 202302L +template +struct A { + // FIXME: The nested-name-specifier in the following friend declarations are declarative, + // but we don't treat them as such (yet). + friend void Ts...[0]::f(); + template + friend void Ts...[0]::g(); + + friend struct Ts...[0]::B; + template + friend struct Ts...[0]::C; // expected-warning{{is not supported; ignoring this friend declaration}} +}; +#endif >From e0646d2098f567ca0cd5642c8694d3d8980134c7 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Tue, 9 Apr 2024 09:03:25 -0400 Subject: [PATCH 2/5] [FOLD] apply review changes --- clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp | 4 ++-- clang/test/CXX/drs/dr28xx.cpp | 21 +++ .../expr.prim.id/expr.prim.id.qual/p3.cpp | 16 -- clang/test/Parser/cxx-class.cpp | 6 +++--- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp index fbe9c0895aeae8..3e67fca9ad7376 100644 --- a/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp +++ b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp @@ -6,8 +6,8 @@ class foo { void func(); }; -int decltype(foo())::i; //
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/88042 >From e850ae0982efbb7cec7c33d6b927844d89128743 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Mon, 8 Apr 2024 09:46:08 -0400 Subject: [PATCH 1/4] [Clang][Sema] Implement approved resolution for CWG2858 --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 7 +++ clang/lib/Sema/SemaDecl.cpp | 13 ++--- .../expr.prim.id/expr.prim.id.qual/p3.cpp| 16 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4fbbc42273ba93..2ce2013aac7362 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2402,10 +2402,6 @@ def err_selected_explicit_constructor : Error< def note_explicit_ctor_deduction_guide_here : Note< "explicit %select{constructor|deduction guide}0 declared here">; -// C++11 decltype -def err_decltype_in_declarator : Error< -"'decltype' cannot be used to name a declaration">; - // C++11 auto def warn_cxx98_compat_auto_type_specifier : Warning< "'auto' type specifier is incompatible with C++98">, @@ -8302,6 +8298,9 @@ def ext_template_after_declarative_nns : ExtWarn< def ext_alias_template_in_declarative_nns : ExtWarn< "a declarative nested name specifier cannot name an alias template">, InGroup>; +def err_computed_type_in_declarative_nns : Error< + "%select{a pack indexing type|'decltype'}0 cannot be used in " + "a declarative nested name specifier">; def err_no_typeid_with_fno_rtti : Error< "use of typeid requires -frtti">; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c790dab72dd721..1ba6b3beb1c758 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6335,16 +6335,15 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec , DeclContext *DC, if (TST->isDependentType() && TST->isTypeAlias()) Diag(Loc, diag::ext_alias_template_in_declarative_nns) << SpecLoc.getLocalSourceRange(); - } else if (T->isDecltypeType()) { + } else if (T->isDecltypeType() || T->getAsAdjusted()) { // C++23 [expr.prim.id.qual]p2: // [...] A declarative nested-name-specifier shall not have a -// decltype-specifier. +// computed-type-specifier. // -// FIXME: This wording appears to be defective as it does not forbid -// declarative nested-name-specifiers with pack-index-specifiers. -// See https://github.com/cplusplus/CWG/issues/499. -Diag(Loc, diag::err_decltype_in_declarator) -<< SpecLoc.getTypeLoc().getSourceRange(); +// CWG2858 changed this from 'decltype-specifier' to +// 'computed-type-specifier'. +Diag(Loc, diag::err_computed_type_in_declarative_nns) +<< T->isDecltypeType() << SpecLoc.getTypeLoc().getSourceRange(); } } } while ((SpecLoc = SpecLoc.getPrefix())); diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp index c73ffa55a26a31..5da13cc22abef2 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -std=c++2c -verify %s template struct A { @@ -27,3 +28,18 @@ namespace N { template void N::E::f() { } // expected-warning {{a declarative nested name specifier cannot name an alias template}} + +#if __cplusplus > 202302L +template +struct A { + // FIXME: The nested-name-specifier in the following friend declarations are declarative, + // but we don't treat them as such (yet). + friend void Ts...[0]::f(); + template + friend void Ts...[0]::g(); + + friend struct Ts...[0]::B; + template + friend struct Ts...[0]::C; // expected-warning{{is not supported; ignoring this friend declaration}} +}; +#endif >From e0646d2098f567ca0cd5642c8694d3d8980134c7 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Tue, 9 Apr 2024 09:03:25 -0400 Subject: [PATCH 2/4] [FOLD] apply review changes --- clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp | 4 ++-- clang/test/CXX/drs/dr28xx.cpp | 21 +++ .../expr.prim.id/expr.prim.id.qual/p3.cpp | 16 -- clang/test/Parser/cxx-class.cpp | 6 +++--- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp index fbe9c0895aeae8..3e67fca9ad7376 100644 --- a/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp +++ b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp @@ -6,8 +6,8 @@ class foo { void func(); }; -int decltype(foo())::i; //
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/88042 >From e850ae0982efbb7cec7c33d6b927844d89128743 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Mon, 8 Apr 2024 09:46:08 -0400 Subject: [PATCH 1/4] [Clang][Sema] Implement approved resolution for CWG2858 --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 7 +++ clang/lib/Sema/SemaDecl.cpp | 13 ++--- .../expr.prim.id/expr.prim.id.qual/p3.cpp| 16 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4fbbc42273ba93..2ce2013aac7362 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2402,10 +2402,6 @@ def err_selected_explicit_constructor : Error< def note_explicit_ctor_deduction_guide_here : Note< "explicit %select{constructor|deduction guide}0 declared here">; -// C++11 decltype -def err_decltype_in_declarator : Error< -"'decltype' cannot be used to name a declaration">; - // C++11 auto def warn_cxx98_compat_auto_type_specifier : Warning< "'auto' type specifier is incompatible with C++98">, @@ -8302,6 +8298,9 @@ def ext_template_after_declarative_nns : ExtWarn< def ext_alias_template_in_declarative_nns : ExtWarn< "a declarative nested name specifier cannot name an alias template">, InGroup>; +def err_computed_type_in_declarative_nns : Error< + "%select{a pack indexing type|'decltype'}0 cannot be used in " + "a declarative nested name specifier">; def err_no_typeid_with_fno_rtti : Error< "use of typeid requires -frtti">; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c790dab72dd721..1ba6b3beb1c758 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6335,16 +6335,15 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec , DeclContext *DC, if (TST->isDependentType() && TST->isTypeAlias()) Diag(Loc, diag::ext_alias_template_in_declarative_nns) << SpecLoc.getLocalSourceRange(); - } else if (T->isDecltypeType()) { + } else if (T->isDecltypeType() || T->getAsAdjusted()) { // C++23 [expr.prim.id.qual]p2: // [...] A declarative nested-name-specifier shall not have a -// decltype-specifier. +// computed-type-specifier. // -// FIXME: This wording appears to be defective as it does not forbid -// declarative nested-name-specifiers with pack-index-specifiers. -// See https://github.com/cplusplus/CWG/issues/499. -Diag(Loc, diag::err_decltype_in_declarator) -<< SpecLoc.getTypeLoc().getSourceRange(); +// CWG2858 changed this from 'decltype-specifier' to +// 'computed-type-specifier'. +Diag(Loc, diag::err_computed_type_in_declarative_nns) +<< T->isDecltypeType() << SpecLoc.getTypeLoc().getSourceRange(); } } } while ((SpecLoc = SpecLoc.getPrefix())); diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp index c73ffa55a26a31..5da13cc22abef2 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -std=c++2c -verify %s template struct A { @@ -27,3 +28,18 @@ namespace N { template void N::E::f() { } // expected-warning {{a declarative nested name specifier cannot name an alias template}} + +#if __cplusplus > 202302L +template +struct A { + // FIXME: The nested-name-specifier in the following friend declarations are declarative, + // but we don't treat them as such (yet). + friend void Ts...[0]::f(); + template + friend void Ts...[0]::g(); + + friend struct Ts...[0]::B; + template + friend struct Ts...[0]::C; // expected-warning{{is not supported; ignoring this friend declaration}} +}; +#endif >From e0646d2098f567ca0cd5642c8694d3d8980134c7 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Tue, 9 Apr 2024 09:03:25 -0400 Subject: [PATCH 2/4] [FOLD] apply review changes --- clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp | 4 ++-- clang/test/CXX/drs/dr28xx.cpp | 21 +++ .../expr.prim.id/expr.prim.id.qual/p3.cpp | 16 -- clang/test/Parser/cxx-class.cpp | 6 +++--- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp index fbe9c0895aeae8..3e67fca9ad7376 100644 --- a/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp +++ b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp @@ -6,8 +6,8 @@ class foo { void func(); }; -int decltype(foo())::i; //
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
@@ -58,3 +58,24 @@ void B::g() requires true; #endif } // namespace dr2847 + +namespace dr2858 { // dr2858: 19 + +#if __cplusplus > 202302L + +template +struct A { + // FIXME: The nested-name-specifier in the following friend declarations are declarative, + // but we don't treat them as such (yet). + friend void Ts...[0]::f(); + template + friend void Ts...[0]::g(); + + friend struct Ts...[0]::B; + template + friend struct Ts...[0]::C; // expected-warning{{is not supported; ignoring this friend declaration}} Endilll wrote: Oh, that's unfortunate. You can still use `expected-warning-re@-1`, and omit the address via regular expression. https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
@@ -58,3 +58,24 @@ void B::g() requires true; #endif } // namespace dr2847 + +namespace dr2858 { // dr2858: 19 + +#if __cplusplus > 202302L + +template +struct A { + // FIXME: The nested-name-specifier in the following friend declarations are declarative, + // but we don't treat them as such (yet). + friend void Ts...[0]::f(); + template + friend void Ts...[0]::g(); + + friend struct Ts...[0]::B; + template + friend struct Ts...[0]::C; // expected-warning{{is not supported; ignoring this friend declaration}} sdkrystian wrote: @Endilll The index of the _pack-index-specifier_ is currently printed as a memory address (as opposed to `0`). I'll be opening another patch to fix that, but that is why some of the diagnostic message is omitted. https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
@@ -58,3 +58,24 @@ void B::g() requires true; #endif } // namespace dr2847 + +namespace dr2858 { // dr2858: 19 + +#if __cplusplus > 202302L + +template +struct A { + // FIXME: The nested-name-specifier in the following friend declarations are declarative, sdkrystian wrote: Not calling `diagnoseQualifiedDeclaration` for friend declarations is unrelated to this DR. Besides that, the only reason we can't write a test to produce this diagnostic is because we compute the `DeclContext` of the _nested-name-specifier_ _before_ `diagnoseQualifiedDeclaration` is called. https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
@@ -58,3 +58,24 @@ void B::g() requires true; #endif } // namespace dr2847 + +namespace dr2858 { // dr2858: 19 + +#if __cplusplus > 202302L + +template +struct A { + // FIXME: The nested-name-specifier in the following friend declarations are declarative, Endilll wrote: Doesn't this mean that we only partially implement the DR? https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
@@ -58,3 +58,24 @@ void B::g() requires true; #endif } // namespace dr2847 + +namespace dr2858 { // dr2858: 19 + +#if __cplusplus > 202302L + +template +struct A { + // FIXME: The nested-name-specifier in the following friend declarations are declarative, + // but we don't treat them as such (yet). + friend void Ts...[0]::f(); + template + friend void Ts...[0]::g(); + + friend struct Ts...[0]::B; + template + friend struct Ts...[0]::C; // expected-warning{{is not supported; ignoring this friend declaration}} Endilll wrote: Like the rest of the file, you should use `expected-warning@-1` style, and include full text of the diagnostic you're matching. https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/Endilll requested changes to this pull request. https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/Endilll edited https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
cor3ntin wrote: > @cor3ntin Should I just move the test from > `test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp` to > `test/CXX/drs/dr28xx.cpp`? Sounds reasonable, yes! https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/88042 >From e850ae0982efbb7cec7c33d6b927844d89128743 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Mon, 8 Apr 2024 09:46:08 -0400 Subject: [PATCH 1/3] [Clang][Sema] Implement approved resolution for CWG2858 --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 7 +++ clang/lib/Sema/SemaDecl.cpp | 13 ++--- .../expr.prim.id/expr.prim.id.qual/p3.cpp| 16 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4fbbc42273ba93..2ce2013aac7362 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2402,10 +2402,6 @@ def err_selected_explicit_constructor : Error< def note_explicit_ctor_deduction_guide_here : Note< "explicit %select{constructor|deduction guide}0 declared here">; -// C++11 decltype -def err_decltype_in_declarator : Error< -"'decltype' cannot be used to name a declaration">; - // C++11 auto def warn_cxx98_compat_auto_type_specifier : Warning< "'auto' type specifier is incompatible with C++98">, @@ -8302,6 +8298,9 @@ def ext_template_after_declarative_nns : ExtWarn< def ext_alias_template_in_declarative_nns : ExtWarn< "a declarative nested name specifier cannot name an alias template">, InGroup>; +def err_computed_type_in_declarative_nns : Error< + "%select{a pack indexing type|'decltype'}0 cannot be used in " + "a declarative nested name specifier">; def err_no_typeid_with_fno_rtti : Error< "use of typeid requires -frtti">; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c790dab72dd721..1ba6b3beb1c758 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6335,16 +6335,15 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec , DeclContext *DC, if (TST->isDependentType() && TST->isTypeAlias()) Diag(Loc, diag::ext_alias_template_in_declarative_nns) << SpecLoc.getLocalSourceRange(); - } else if (T->isDecltypeType()) { + } else if (T->isDecltypeType() || T->getAsAdjusted()) { // C++23 [expr.prim.id.qual]p2: // [...] A declarative nested-name-specifier shall not have a -// decltype-specifier. +// computed-type-specifier. // -// FIXME: This wording appears to be defective as it does not forbid -// declarative nested-name-specifiers with pack-index-specifiers. -// See https://github.com/cplusplus/CWG/issues/499. -Diag(Loc, diag::err_decltype_in_declarator) -<< SpecLoc.getTypeLoc().getSourceRange(); +// CWG2858 changed this from 'decltype-specifier' to +// 'computed-type-specifier'. +Diag(Loc, diag::err_computed_type_in_declarative_nns) +<< T->isDecltypeType() << SpecLoc.getTypeLoc().getSourceRange(); } } } while ((SpecLoc = SpecLoc.getPrefix())); diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp index c73ffa55a26a31..5da13cc22abef2 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -std=c++2c -verify %s template struct A { @@ -27,3 +28,18 @@ namespace N { template void N::E::f() { } // expected-warning {{a declarative nested name specifier cannot name an alias template}} + +#if __cplusplus > 202302L +template +struct A { + // FIXME: The nested-name-specifier in the following friend declarations are declarative, + // but we don't treat them as such (yet). + friend void Ts...[0]::f(); + template + friend void Ts...[0]::g(); + + friend struct Ts...[0]::B; + template + friend struct Ts...[0]::C; // expected-warning{{is not supported; ignoring this friend declaration}} +}; +#endif >From e0646d2098f567ca0cd5642c8694d3d8980134c7 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Tue, 9 Apr 2024 09:03:25 -0400 Subject: [PATCH 2/3] [FOLD] apply review changes --- clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp | 4 ++-- clang/test/CXX/drs/dr28xx.cpp | 21 +++ .../expr.prim.id/expr.prim.id.qual/p3.cpp | 16 -- clang/test/Parser/cxx-class.cpp | 6 +++--- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp index fbe9c0895aeae8..3e67fca9ad7376 100644 --- a/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp +++ b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp @@ -6,8 +6,8 @@ class foo { void func(); }; -int decltype(foo())::i; //
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/88042 Unicorn! GitHub body { background-color: #f1f1f1; margin: 0; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; } .container { margin: 50px auto 40px auto; width: 600px; text-align: center; } a { color: #4183c4; text-decoration: none; } a:hover { text-decoration: underline; } h1 { letter-spacing: -1px; line-height: 60px; font-size: 60px; font-weight: 100; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 10px 0 10px; font-size: 18px; font-weight: 200; line-height: 1.6em;} ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } We had issues producing the response to your request. Sorry about that. Please try refreshing and contact us if the problem persists. https://github.com/contact;>Contact Support https://www.githubstatus.com;>GitHub Status https://twitter.com/githubstatus;>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
sdkrystian wrote: @cor3ntin Should I just move the test from `test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp` to `test/CXX/drs/dr28xx.cpp`? https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
cor3ntin wrote: This needs a release note and a test in test/CXX/drs/dr28xx.cpp (and a rerun of www/make_cxx_dr_status ) https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/erichkeane approved this pull request. This seems right to me, thanks! https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/sdkrystian edited https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Krystian Stasiowski (sdkrystian) Changes The approved resolution for [CWG2858](https://cplusplus.github.io/CWG/issues/2858.html) changes [[expr.prim.id.qual] p2 sentence 2](https://eel.is/c++draft/expr.prim.id.qual#2) to read: A declarative _nested-name-specifier_ shall not have a _computed-type-specifier_. This patch implements the approved resolution. Since we don't consider _nested-name-specifiers_ in friend declarations to be declarative (yet), it currently isn't possible to write a test that would produce this diagnostic (`diagnoseQualifiedDeclaration` is never called if the `DeclContext` can't be computed). Nevertheless, tests were added which will produce the diagnostic once we start calling `diagnoseQualifiedDeclaration` for friend declarations. --- Full diff: https://github.com/llvm/llvm-project/pull/88042.diff 3 Files Affected: - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+3-4) - (modified) clang/lib/Sema/SemaDecl.cpp (+6-7) - (modified) clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp (+16) ``diff diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index a1dda2d2461c31..2b9077173aa426 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2402,10 +2402,6 @@ def err_selected_explicit_constructor : Error< def note_explicit_ctor_deduction_guide_here : Note< "explicit %select{constructor|deduction guide}0 declared here">; -// C++11 decltype -def err_decltype_in_declarator : Error< -"'decltype' cannot be used to name a declaration">; - // C++11 auto def warn_cxx98_compat_auto_type_specifier : Warning< "'auto' type specifier is incompatible with C++98">, @@ -8302,6 +8298,9 @@ def ext_template_after_declarative_nns : ExtWarn< def ext_alias_template_in_declarative_nns : ExtWarn< "a declarative nested name specifier cannot name an alias template">, InGroup>; +def err_computed_type_in_declarative_nns : Error< + "%select{a pack indexing type|'decltype'}0 cannot be used in " + "a declarative nested name specifier">; def err_no_typeid_with_fno_rtti : Error< "use of typeid requires -frtti">; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c790dab72dd721..1ba6b3beb1c758 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6335,16 +6335,15 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec , DeclContext *DC, if (TST->isDependentType() && TST->isTypeAlias()) Diag(Loc, diag::ext_alias_template_in_declarative_nns) << SpecLoc.getLocalSourceRange(); - } else if (T->isDecltypeType()) { + } else if (T->isDecltypeType() || T->getAsAdjusted()) { // C++23 [expr.prim.id.qual]p2: // [...] A declarative nested-name-specifier shall not have a -// decltype-specifier. +// computed-type-specifier. // -// FIXME: This wording appears to be defective as it does not forbid -// declarative nested-name-specifiers with pack-index-specifiers. -// See https://github.com/cplusplus/CWG/issues/499. -Diag(Loc, diag::err_decltype_in_declarator) -<< SpecLoc.getTypeLoc().getSourceRange(); +// CWG2858 changed this from 'decltype-specifier' to +// 'computed-type-specifier'. +Diag(Loc, diag::err_computed_type_in_declarative_nns) +<< T->isDecltypeType() << SpecLoc.getTypeLoc().getSourceRange(); } } } while ((SpecLoc = SpecLoc.getPrefix())); diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp index c73ffa55a26a31..5da13cc22abef2 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -std=c++2c -verify %s template struct A { @@ -27,3 +28,18 @@ namespace N { template void N::E::f() { } // expected-warning {{a declarative nested name specifier cannot name an alias template}} + +#if __cplusplus > 202302L +template +struct A { + // FIXME: The nested-name-specifier in the following friend declarations are declarative, + // but we don't treat them as such (yet). + friend void Ts...[0]::f(); + template + friend void Ts...[0]::g(); + + friend struct Ts...[0]::B; + template + friend struct Ts...[0]::C; // expected-warning{{is not supported; ignoring this friend declaration}} +}; +#endif `` https://github.com/llvm/llvm-project/pull/88042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/88042 >From 9c3b78f1f37049224f31e3bcd07ae8d762b760d1 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Mon, 8 Apr 2024 09:46:08 -0400 Subject: [PATCH] [Clang][Sema] Implement approved resolution for CWG2858 --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 7 +++ clang/lib/Sema/SemaDecl.cpp | 13 ++--- .../expr.prim.id/expr.prim.id.qual/p3.cpp| 16 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index a1dda2d2461c31..2b9077173aa426 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2402,10 +2402,6 @@ def err_selected_explicit_constructor : Error< def note_explicit_ctor_deduction_guide_here : Note< "explicit %select{constructor|deduction guide}0 declared here">; -// C++11 decltype -def err_decltype_in_declarator : Error< -"'decltype' cannot be used to name a declaration">; - // C++11 auto def warn_cxx98_compat_auto_type_specifier : Warning< "'auto' type specifier is incompatible with C++98">, @@ -8302,6 +8298,9 @@ def ext_template_after_declarative_nns : ExtWarn< def ext_alias_template_in_declarative_nns : ExtWarn< "a declarative nested name specifier cannot name an alias template">, InGroup>; +def err_computed_type_in_declarative_nns : Error< + "%select{a pack indexing type|'decltype'}0 cannot be used in " + "a declarative nested name specifier">; def err_no_typeid_with_fno_rtti : Error< "use of typeid requires -frtti">; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c790dab72dd721..1ba6b3beb1c758 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6335,16 +6335,15 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec , DeclContext *DC, if (TST->isDependentType() && TST->isTypeAlias()) Diag(Loc, diag::ext_alias_template_in_declarative_nns) << SpecLoc.getLocalSourceRange(); - } else if (T->isDecltypeType()) { + } else if (T->isDecltypeType() || T->getAsAdjusted()) { // C++23 [expr.prim.id.qual]p2: // [...] A declarative nested-name-specifier shall not have a -// decltype-specifier. +// computed-type-specifier. // -// FIXME: This wording appears to be defective as it does not forbid -// declarative nested-name-specifiers with pack-index-specifiers. -// See https://github.com/cplusplus/CWG/issues/499. -Diag(Loc, diag::err_decltype_in_declarator) -<< SpecLoc.getTypeLoc().getSourceRange(); +// CWG2858 changed this from 'decltype-specifier' to +// 'computed-type-specifier'. +Diag(Loc, diag::err_computed_type_in_declarative_nns) +<< T->isDecltypeType() << SpecLoc.getTypeLoc().getSourceRange(); } } } while ((SpecLoc = SpecLoc.getPrefix())); diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp index c73ffa55a26a31..5da13cc22abef2 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -std=c++2c -verify %s template struct A { @@ -27,3 +28,18 @@ namespace N { template void N::E::f() { } // expected-warning {{a declarative nested name specifier cannot name an alias template}} + +#if __cplusplus > 202302L +template +struct A { + // FIXME: The nested-name-specifier in the following friend declarations are declarative, + // but we don't treat them as such (yet). + friend void Ts...[0]::f(); + template + friend void Ts...[0]::g(); + + friend struct Ts...[0]::B; + template + friend struct Ts...[0]::C; // expected-warning{{is not supported; ignoring this friend declaration}} +}; +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)
https://github.com/sdkrystian created https://github.com/llvm/llvm-project/pull/88042 The approved resolution for [CWG2858](https://cplusplus.github.io/CWG/issues/2858.html) changes [[expr.prim.id.qual] p2 sentence 2](https://eel.is/c++draft/expr.prim.id.qual#2) to read: > A declarative _nested-name-specifier_ shall not have a > _computed-type-specifier_. This patch implements the approved resolution. Since we don't consider _nested-name-specifiers_ in friend declarations to be declarative (yet), it currently isn't possible to write a test that would produce this diagnostic (`diagnoseQualifiedDeclaration` is never called if the `DeclContext` can't be computed). Nevertheless, tests were added which will produce the diagnostic once we start calling `diagnoseQualifiedDeclaration` for friend declarations. >From 5f06642fa89d517adbb11157fa88352bd86d79bf Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Mon, 8 Apr 2024 09:46:08 -0400 Subject: [PATCH] [Clang][Sema] Implement accepted resolution for CWG2858 --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 7 +++ clang/lib/Sema/SemaDecl.cpp | 13 ++--- .../expr.prim.id/expr.prim.id.qual/p3.cpp| 16 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index a1dda2d2461c31..2b9077173aa426 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2402,10 +2402,6 @@ def err_selected_explicit_constructor : Error< def note_explicit_ctor_deduction_guide_here : Note< "explicit %select{constructor|deduction guide}0 declared here">; -// C++11 decltype -def err_decltype_in_declarator : Error< -"'decltype' cannot be used to name a declaration">; - // C++11 auto def warn_cxx98_compat_auto_type_specifier : Warning< "'auto' type specifier is incompatible with C++98">, @@ -8302,6 +8298,9 @@ def ext_template_after_declarative_nns : ExtWarn< def ext_alias_template_in_declarative_nns : ExtWarn< "a declarative nested name specifier cannot name an alias template">, InGroup>; +def err_computed_type_in_declarative_nns : Error< + "%select{a pack indexing type|'decltype'}0 cannot be used in " + "a declarative nested name specifier">; def err_no_typeid_with_fno_rtti : Error< "use of typeid requires -frtti">; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c790dab72dd721..1ba6b3beb1c758 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6335,16 +6335,15 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec , DeclContext *DC, if (TST->isDependentType() && TST->isTypeAlias()) Diag(Loc, diag::ext_alias_template_in_declarative_nns) << SpecLoc.getLocalSourceRange(); - } else if (T->isDecltypeType()) { + } else if (T->isDecltypeType() || T->getAsAdjusted()) { // C++23 [expr.prim.id.qual]p2: // [...] A declarative nested-name-specifier shall not have a -// decltype-specifier. +// computed-type-specifier. // -// FIXME: This wording appears to be defective as it does not forbid -// declarative nested-name-specifiers with pack-index-specifiers. -// See https://github.com/cplusplus/CWG/issues/499. -Diag(Loc, diag::err_decltype_in_declarator) -<< SpecLoc.getTypeLoc().getSourceRange(); +// CWG2858 changed this from 'decltype-specifier' to +// 'computed-type-specifier'. +Diag(Loc, diag::err_computed_type_in_declarative_nns) +<< T->isDecltypeType() << SpecLoc.getTypeLoc().getSourceRange(); } } } while ((SpecLoc = SpecLoc.getPrefix())); diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp index c73ffa55a26a31..5da13cc22abef2 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -std=c++2c -verify %s template struct A { @@ -27,3 +28,18 @@ namespace N { template void N::E::f() { } // expected-warning {{a declarative nested name specifier cannot name an alias template}} + +#if __cplusplus > 202302L +template +struct A { + // FIXME: The nested-name-specifier in the following friend declarations are declarative, + // but we don't treat them as such (yet). + friend void Ts...[0]::f(); + template + friend void Ts...[0]::g(); + + friend struct Ts...[0]::B; + template + friend struct Ts...[0]::C; // expected-warning{{is not supported; ignoring this friend declaration}} +}; +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org