c++/modules: Don't emit imported deduction guides [PR117397]
The ICE in the linked PR is caused because name lookup finds duplicate copies of the deduction guides, causing a checking assert to fail. This is ultimately because we're exporting an imported guide; when name lookup processes 'dguide-5_b.H' it goes via the 'tt_entity' path and just returns the entity from 'dguide-5_a.H'. Because this doesn't ever go through 'key_mergeable' we never set 'BINDING_VECTOR_GLOBAL_DUPS_P' and so deduping is not engaged, allowing duplicate results. Currently I believe this to be a perculiarity of the ANY_REACHABLE handling for deduction guides; in no other case that I can find do we emit bindings purely to imported entities. As such, this patch fixes this problem from that end, by ensuring that we simply do not emit any imported deduction guides. This avoids the ICE because no duplicates need deduping to start with, and should otherwise have no functional change because lookup of deduction guides will look at all reachable modules (exported or not) regardless. Since we're now deliberately not emitting imported deduction guides we can use LOOK_want::NORMAL instead of LOOK_want::ANY_REACHABLE, since the extra work to find as-yet undiscovered deduction guides in transitive importers is not necessary here. PR c++/117397 gcc/cp/ChangeLog: * module.cc (depset::hash::add_deduction_guides): Don't emit imported deduction guides. (depset::hash::finalize_dependencies): Add check for any bindings referring to imported entities. gcc/testsuite/ChangeLog: * g++.dg/modules/dguide-5_a.H: New test. * g++.dg/modules/dguide-5_b.H: New test. * g++.dg/modules/dguide-5_c.H: New test. * g++.dg/modules/dguide-6.h: New test. * g++.dg/modules/dguide-6_a.C: New test. * g++.dg/modules/dguide-6_b.C: New test. * g++.dg/modules/dguide-6_c.C: New test. Signed-off-by:Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by:
Jason Merrill <jason@redhat.com>
Showing
- gcc/cp/module.cc 25 additions, 10 deletionsgcc/cp/module.cc
- gcc/testsuite/g++.dg/modules/dguide-5_a.H 6 additions, 0 deletionsgcc/testsuite/g++.dg/modules/dguide-5_a.H
- gcc/testsuite/g++.dg/modules/dguide-5_b.H 6 additions, 0 deletionsgcc/testsuite/g++.dg/modules/dguide-5_b.H
- gcc/testsuite/g++.dg/modules/dguide-5_c.H 7 additions, 0 deletionsgcc/testsuite/g++.dg/modules/dguide-5_c.H
- gcc/testsuite/g++.dg/modules/dguide-6.h 4 additions, 0 deletionsgcc/testsuite/g++.dg/modules/dguide-6.h
- gcc/testsuite/g++.dg/modules/dguide-6_a.C 7 additions, 0 deletionsgcc/testsuite/g++.dg/modules/dguide-6_a.C
- gcc/testsuite/g++.dg/modules/dguide-6_b.C 8 additions, 0 deletionsgcc/testsuite/g++.dg/modules/dguide-6_b.C
- gcc/testsuite/g++.dg/modules/dguide-6_c.C 12 additions, 0 deletionsgcc/testsuite/g++.dg/modules/dguide-6_c.C
Loading
Please register or sign in to comment