Skip to content
Snippets Groups Projects
Commit e668771f authored by Nathaniel Shead's avatar Nathaniel Shead
Browse files

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: default avatarNathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: default avatarJason Merrill <jason@redhat.com>
parent c7b76a07
No related branches found
No related tags found
No related merge requests found
Showing
with 26 additions and 49 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment