]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: more checks for exporting names with using-declarations
authorNathaniel Shead <nathanieloshead@gmail.com>
Fri, 10 Nov 2023 03:28:40 +0000 (14:28 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Sat, 25 Nov 2023 01:44:17 +0000 (12:44 +1100)
commit1f70291b93a07178bb645273cdd80c404d77ba2f
tree1feca8b9e05e19e61e43a6bf0e3849648afee788
parent9dd8be6fc2debc4fbd0950386d4e98878af27a45
c++: more checks for exporting names with using-declarations

Currently only functions are directly checked for validity when
exporting via a using-declaration.  This patch also checks exporting
non-external names of variables, types, and enumerators.  This also
prevents ICEs with `export using enum` for internal-linkage enums.

While we're at it this patch also improves the error messages for these
cases to provide more context about what went wrong.

gcc/cp/ChangeLog:

* name-lookup.cc (check_can_export_using_decl): New.
(do_nonmember_using_decl): Use above to check if names can be
exported.

gcc/testsuite/ChangeLog:

* g++.dg/modules/using-10.C: New test.
* g++.dg/modules/using-enum-2.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
gcc/cp/name-lookup.cc
gcc/testsuite/g++.dg/modules/using-10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/using-enum-2.C [new file with mode: 0644]