public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100862] New: using enum member access fail
@ 2021-06-01 19:53 eligorkadaf at gmail dot com
  2021-06-02  9:33 ` [Bug c++/100862] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: eligorkadaf at gmail dot com @ 2021-06-01 19:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100862

            Bug ID: 100862
           Summary: using enum member access fail
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eligorkadaf at gmail dot com
  Target Milestone: ---

The following code must compile according to C++20 standard. However, gcc fails
to compile it

enum class fruit { orange, apple };

struct Working {
    using enum fruit;
};

struct Broken {
    using enum fruit;
private:
};

int main() {
    Working::orange;
    Broken::orange;
}

Link to godbolt(I don't have gcc-11 installed): https://godbolt.org/z/srYj3sMno

Link to C++-draft clause: http://eel.is/c++draft/namespace.udecl#16

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100862] using enum member access fail
  2021-06-01 19:53 [Bug c++/100862] New: using enum member access fail eligorkadaf at gmail dot com
@ 2021-06-02  9:33 ` redi at gcc dot gnu.org
  2021-06-02 12:46 ` ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-02  9:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100862

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-06-02
             Status|UNCONFIRMED                 |NEW

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100862] using enum member access fail
  2021-06-01 19:53 [Bug c++/100862] New: using enum member access fail eligorkadaf at gmail dot com
  2021-06-02  9:33 ` [Bug c++/100862] " redi at gcc dot gnu.org
@ 2021-06-02 12:46 ` ppalka at gcc dot gnu.org
  2021-06-03 13:39 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-06-02 12:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100862

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100862] using enum member access fail
  2021-06-01 19:53 [Bug c++/100862] New: using enum member access fail eligorkadaf at gmail dot com
  2021-06-02  9:33 ` [Bug c++/100862] " redi at gcc dot gnu.org
  2021-06-02 12:46 ` ppalka at gcc dot gnu.org
@ 2021-06-03 13:39 ` cvs-commit at gcc dot gnu.org
  2021-06-07 22:37 ` cvs-commit at gcc dot gnu.org
  2021-06-07 22:58 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-03 13:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100862

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:69f517ac20566a645ff41a9bfca535822205a538

commit r12-1182-g69f517ac20566a645ff41a9bfca535822205a538
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Jun 3 09:37:11 2021 -0400

    c++: using-enum and access specifiers [PR100862]

    When copying the enumerators imported by a class-scope using-enum
    declaration, we need to override current_access_specifier so that
    finish_member_declaration gives the copies the same access as the
    using-enum decl.  (A class-scope using-enum is processed late, so
    current_access_specifier at this point is otherwise set to the last
    access specifier within the class.)  To that end, this patch makes
    handle_using_decl call set_current_access_from_decl accordingly.

    For consistency, this patch makes build_enumerator use
    set_current_access_from_decl too.

            PR c++/100862

    gcc/cp/ChangeLog:

            * pt.c (set_current_access_from_decl): Move to ...
            * class.c (set_current_access_from_decl): ... here.
            (handle_using_decl): Use it to propagate the access of the
            using-enum decl to the copy of the imported enumerator.
            * cp-tree.h (set_current_access_from_decl): Declare.
            * decl.c (build_enumerator): Simplify using make_temp_override
            and set_current_access_from_decl.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/using-enum-9.C: New test.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100862] using enum member access fail
  2021-06-01 19:53 [Bug c++/100862] New: using enum member access fail eligorkadaf at gmail dot com
                   ` (2 preceding siblings ...)
  2021-06-03 13:39 ` cvs-commit at gcc dot gnu.org
@ 2021-06-07 22:37 ` cvs-commit at gcc dot gnu.org
  2021-06-07 22:58 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-07 22:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100862

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:e62029a785b3a5e98123da6ef01ca94c003c306d

commit r11-8521-ge62029a785b3a5e98123da6ef01ca94c003c306d
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Jun 3 09:37:11 2021 -0400

    c++: using-enum and access specifiers [PR100862]

    When copying the enumerators imported by a class-scope using-enum
    declaration, we need to override current_access_specifier so that
    finish_member_declaration gives the copies the same access as the
    using-enum decl.  (A class-scope using-enum is processed late, so
    current_access_specifier at this point is otherwise set to the last
    access specifier within the class.)  To that end, this patch makes
    handle_using_decl call set_current_access_from_decl accordingly.

    For consistency, this patch makes build_enumerator use
    set_current_access_from_decl too.

            PR c++/100862

    gcc/cp/ChangeLog:

            * pt.c (set_current_access_from_decl): Move to ...
            * class.c (set_current_access_from_decl): ... here.
            (handle_using_decl): Use it to propagate the access of the
            using-enum decl to the copy of the imported enumerator.
            * cp-tree.h (set_current_access_from_decl): Declare.
            * decl.c (build_enumerator): Simplify using make_temp_override
            and set_current_access_from_decl.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/using-enum-9.C: New test.

    (cherry picked from commit 69f517ac20566a645ff41a9bfca535822205a538)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100862] using enum member access fail
  2021-06-01 19:53 [Bug c++/100862] New: using enum member access fail eligorkadaf at gmail dot com
                   ` (3 preceding siblings ...)
  2021-06-07 22:37 ` cvs-commit at gcc dot gnu.org
@ 2021-06-07 22:58 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-06-07 22:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100862

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.2
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 11.2 and 12, thanks for the bug report.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-06-07 22:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-01 19:53 [Bug c++/100862] New: using enum member access fail eligorkadaf at gmail dot com
2021-06-02  9:33 ` [Bug c++/100862] " redi at gcc dot gnu.org
2021-06-02 12:46 ` ppalka at gcc dot gnu.org
2021-06-03 13:39 ` cvs-commit at gcc dot gnu.org
2021-06-07 22:37 ` cvs-commit at gcc dot gnu.org
2021-06-07 22:58 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).