]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: using-enum and access specifiers [PR100862]
authorPatrick Palka <ppalka@redhat.com>
Thu, 3 Jun 2021 13:37:11 +0000 (09:37 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 3 Jun 2021 13:37:11 +0000 (09:37 -0400)
commit69f517ac20566a645ff41a9bfca535822205a538
tree2875107dbf5de313799318d11e5d0f1c1f3da5f7
parent7ed1cd9665d8ca0fa07b2483e604c25e704584af
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.
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp2a/using-enum-9.C [new file with mode: 0644]