]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++/modules: Handle redefinitions of using-decls
authorNathaniel Shead <nathanieloshead@gmail.com>
Fri, 5 Jul 2024 03:52:01 +0000 (13:52 +1000)
committerNathaniel Shead <nathanieloshead@gmail.com>
Fri, 12 Jul 2024 12:47:30 +0000 (22:47 +1000)
commit1f7a21c6e85d553e7b5114e5ca1395118478dddf
tree197b272814e2610799b032cfaec7fb6688ad2bbe
parentd6bf4b1c93221118b3008a878ec508f6412dfc55
c++/modules: Handle redefinitions of using-decls

This fixes an ICE exposed by supporting exported non-function
using-decls.  Sometimes when preparing to define a class, xref_tag will
find a using-decl belonging to a different namespace, which triggers the
checking_assert in modules handling.

Ideally I feel that 'lookup_and_check_tag' should be told whether we're
about to define the type and handle erroring on redefinitions itself to
avoid this issue (and provide better diagnostics by acknowledging the
using-declaration), but this is complicated with the current
fragmentation of definition checking.  So for this patch we just fixup
the assertion and ensure that pushdecl properly errors on the
conflicting declaration later.

gcc/cp/ChangeLog:

* decl.cc (xref_tag): Move assertion into condition.
* name-lookup.cc (check_module_override): Check for conflicting
types and using-decls.

gcc/testsuite/ChangeLog:

* g++.dg/modules/using-19_a.C: New test.
* g++.dg/modules/using-19_b.C: New test.

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