c++/modules: Remove unnecessary errors when not writing compiled module
It was pointed out to me that the current error referencing an internal linkage entity reads almost like an ICE message, with the message finishing with the unhelpful: m.cpp:1:8: error: failed to write compiled module: Bad file data 1 | export module M; | ^~~~~~ Similarly, whenever we decide not to emit a module CMI due to other errors we currently emit the following message: m.cpp:1:8: warning: not writing module ‘M’ due to errors 1 | export module M; | ^~~~~~ Neither of these messages really add anything useful; users already understand that when an error is reported then the normal outputs will not be created, so these messages are just noise. There is one case we still need this latter message, however; when an error in a template has been silenced with '-Wno-template-body' we still don't want to write a module CMI, so emit an error now instead. This patch also removes a number of dg-prune-output directives in the testsuite that are no longer needed with this change. gcc/cp/ChangeLog: * module.cc (module_state::write_begin): Return a boolean to indicate errors rather than just doing set_error(). (finish_module_processing): Prevent emission of unnecessary errors; only indicate module writing occurred if write_begin succeeds. gcc/testsuite/ChangeLog: * g++.dg/modules/export-1.C: Remove message. * g++.dg/modules/internal-1.C: Remove message. * g++.dg/modules/ambig-2_b.C: Remove unnecessary pruning. * g++.dg/modules/atom-decl-2.C: Likewise. * g++.dg/modules/atom-pragma-3.C: Likewise. * g++.dg/modules/atom-preamble-2_f.C: Likewise. * g++.dg/modules/block-decl-2.C: Likewise. * g++.dg/modules/dir-only-4.C: Likewise. * g++.dg/modules/enum-12.C: Likewise. * g++.dg/modules/exp-xlate-1_b.C: Likewise. * g++.dg/modules/export-3.C: Likewise. * g++.dg/modules/friend-3.C: Likewise. * g++.dg/modules/friend-5_b.C: Likewise. * g++.dg/modules/inc-xlate-1_e.C: Likewise. * g++.dg/modules/linkage-2.C: Likewise. * g++.dg/modules/local-extern-1.C: Likewise. * g++.dg/modules/main-1.C: Likewise. * g++.dg/modules/map-2.C: Likewise. * g++.dg/modules/mod-decl-1.C: Likewise. * g++.dg/modules/mod-decl-3.C: Likewise. * g++.dg/modules/pr99174.H: Likewise. * g++.dg/modules/pr99468.H: Likewise. * g++.dg/modules/token-1.C: Likewise. * g++.dg/modules/token-3.C: Likewise. * g++.dg/modules/token-4.C: Likewise. * g++.dg/modules/token-5.C: Likewise. * g++.dg/modules/using-10.C: Likewise. * g++.dg/modules/using-12.C: Likewise. * g++.dg/modules/using-3.C: Likewise. * g++.dg/modules/using-9.C: Likewise. * g++.dg/modules/using-enum-2.C: Likewise. * g++.dg/modules/permissive-error-1.C: New test. * g++.dg/modules/permissive-error-2.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, 17 deletionsgcc/cp/module.cc
- gcc/testsuite/g++.dg/modules/ambig-2_b.C 0 additions, 2 deletionsgcc/testsuite/g++.dg/modules/ambig-2_b.C
- gcc/testsuite/g++.dg/modules/atom-decl-2.C 0 additions, 2 deletionsgcc/testsuite/g++.dg/modules/atom-decl-2.C
- gcc/testsuite/g++.dg/modules/atom-pragma-3.C 0 additions, 2 deletionsgcc/testsuite/g++.dg/modules/atom-pragma-3.C
- gcc/testsuite/g++.dg/modules/atom-preamble-2_f.C 0 additions, 1 deletiongcc/testsuite/g++.dg/modules/atom-preamble-2_f.C
- gcc/testsuite/g++.dg/modules/block-decl-2.C 0 additions, 2 deletionsgcc/testsuite/g++.dg/modules/block-decl-2.C
- gcc/testsuite/g++.dg/modules/dir-only-4.C 0 additions, 1 deletiongcc/testsuite/g++.dg/modules/dir-only-4.C
- gcc/testsuite/g++.dg/modules/enum-12.C 0 additions, 2 deletionsgcc/testsuite/g++.dg/modules/enum-12.C
- gcc/testsuite/g++.dg/modules/exp-xlate-1_b.C 0 additions, 1 deletiongcc/testsuite/g++.dg/modules/exp-xlate-1_b.C
- gcc/testsuite/g++.dg/modules/export-1.C 0 additions, 2 deletionsgcc/testsuite/g++.dg/modules/export-1.C
- gcc/testsuite/g++.dg/modules/export-3.C 0 additions, 2 deletionsgcc/testsuite/g++.dg/modules/export-3.C
- gcc/testsuite/g++.dg/modules/friend-3.C 0 additions, 1 deletiongcc/testsuite/g++.dg/modules/friend-3.C
- gcc/testsuite/g++.dg/modules/friend-5_b.C 0 additions, 1 deletiongcc/testsuite/g++.dg/modules/friend-5_b.C
- gcc/testsuite/g++.dg/modules/inc-xlate-1_e.C 0 additions, 2 deletionsgcc/testsuite/g++.dg/modules/inc-xlate-1_e.C
- gcc/testsuite/g++.dg/modules/internal-1.C 1 addition, 1 deletiongcc/testsuite/g++.dg/modules/internal-1.C
- gcc/testsuite/g++.dg/modules/linkage-2.C 0 additions, 2 deletionsgcc/testsuite/g++.dg/modules/linkage-2.C
- gcc/testsuite/g++.dg/modules/local-extern-1.C 0 additions, 3 deletionsgcc/testsuite/g++.dg/modules/local-extern-1.C
- gcc/testsuite/g++.dg/modules/main-1.C 0 additions, 1 deletiongcc/testsuite/g++.dg/modules/main-1.C
- gcc/testsuite/g++.dg/modules/map-2.C 0 additions, 2 deletionsgcc/testsuite/g++.dg/modules/map-2.C
- gcc/testsuite/g++.dg/modules/mod-decl-1.C 0 additions, 2 deletionsgcc/testsuite/g++.dg/modules/mod-decl-1.C
Loading
Please register or sign in to comment