]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++/modules: Handle transitive reachability for deduction guides [PR116403]
authorNathaniel Shead <nathanieloshead@gmail.com>
Sun, 18 Aug 2024 01:36:40 +0000 (11:36 +1000)
committerNathaniel Shead <nathanieloshead@gmail.com>
Tue, 20 Aug 2024 07:14:11 +0000 (17:14 +1000)
commit6f115a8eeea41d383dfb1bbb1af6ac9a97aee180
tree7515e1d1a7735749ce8edc56b19125bb5e0a4f79
parent0b7904e274fbd6a736d63c0fed28ea32f9cb5997
c++/modules: Handle transitive reachability for deduction guides [PR116403]

Currently we implement [temp.deduct.guide] p1 by forcing all deduction
guides to be considered as exported.  However this is not sufficient:
for transitive non-exported imports we will still hide the deduction
guide from name lookup, causing errors.

This patch instead adjusts name lookup to have a new ANY_REACHABLE flag
to allow for this case.  Currently this is only used by deduction guides
but there are some other circumstances where this may be useful in the
future (e.g. finding existing temploid friends).

PR c++/116403

gcc/cp/ChangeLog:

* pt.cc (deduction_guides_for): Use ANY_REACHABLE for lookup of
deduction guides.
* module.cc (depset::hash::add_deduction_guides): Likewise.
(module_state::write_cluster): No longer override deduction
guides as exported.
* name-lookup.cc (name_lookup::search_namespace_only): Ignore
visibility when LOOK_want::ANY_REACHABLE is specified.
(check_module_override): Ignore visibility when checking for
ambiguating deduction guides.
* name-lookup.h (LOOK_want): New flag 'ANY_REACHABLE'.

gcc/testsuite/ChangeLog:

* g++.dg/modules/dguide-4_a.C: New test.
* g++.dg/modules/dguide-4_b.C: New test.
* g++.dg/modules/dguide-4_c.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/module.cc
gcc/cp/name-lookup.cc
gcc/cp/name-lookup.h
gcc/cp/pt.cc
gcc/testsuite/g++.dg/modules/dguide-4_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/dguide-4_b.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/dguide-4_c.C [new file with mode: 0644]