c++/modules: Avoid rechecking initializers when streaming NTTPs [PR116382]
When reading an NTTP we call get_template_parm_object which delegates setting of DECL_INITIAL to the general cp_finish_decl procedure, which calls check_initializer to validate and record it. Apart from being unnecessary (it must have already been validated by the writing module), this also causes errors in cases like the linked PR, as validating may end up needing to call lazy_load_pendings to determine any specialisations that may exist which violates assumptions of the modules streaming code. This patch works around the issue by adding a flag to get_template_parm_object to disable these checks when not needed. PR c++/116382 gcc/cp/ChangeLog: * cp-tree.h (get_template_parm_object): Add check_init param. * module.cc (trees_in::tree_node): Pass check_init=false when building NTTPs. * pt.cc (get_template_parm_object): Prevent cp_finish_decl from validating the initializer when check_init=false. gcc/testsuite/ChangeLog: * g++.dg/modules/tpl-nttp-1_a.C: New test. * g++.dg/modules/tpl-nttp-1_b.C: New test. Signed-off-by:Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by:
Jason Merrill <jason@redhat.com>
Showing
- gcc/cp/cp-tree.h 2 additions, 1 deletiongcc/cp/cp-tree.h
- gcc/cp/module.cc 5 additions, 1 deletiongcc/cp/module.cc
- gcc/cp/pt.cc 14 additions, 4 deletionsgcc/cp/pt.cc
- gcc/testsuite/g++.dg/modules/tpl-nttp-1_a.C 8 additions, 0 deletionsgcc/testsuite/g++.dg/modules/tpl-nttp-1_a.C
- gcc/testsuite/g++.dg/modules/tpl-nttp-1_b.C 6 additions, 0 deletionsgcc/testsuite/g++.dg/modules/tpl-nttp-1_b.C
Loading
Please register or sign in to comment