This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] fix problem with error return code


Tested on i686-linux, committed on trunk

This patch corrects a problem with the error return code. If a program
generates warnings that are all suppressed using the specific text form
of pragma Warnings (Off), and the -gnatwe (treat warnings as errors)
flag is set, then even though there are no warnings generated (and
no errors), the return code indicates an error. That was because the
test for compilation errors was done before the suppression was carried
out. This is resolved by splitting Finalize into two routines, one,
called Finalize (the old name for both functions) which does the
suppression, and is to be called before a Compilation_Errors
call, and one (the new routine Output_Messages), which outputs the
actual messages.

gnat.dg/warn1.adb illustrates the problem:

procedure warn1 is
   pragma Warnings
     (Off, "variable ""Unused"" is never read and assigned");
   Unused : Integer;
   pragma Warnings
     (On, "variable ""Unused"" is never read and assigned");
begin
   null;
end warn1;

Without this patch, if you try to do a gnatmake on this procedure,
you get:

gcc -c -gnatwae eg.adb
gnatmake: "eg.adb" compilation error

But with the patch, this program compiles silently, and can be
executed (doing nothing).

2007-06-06  Robert Dewar  <dewar@adacore.com>

	* comperr.adb (Compiler_Abort): New Finalize/Output_Messages interface
	for Errout

	* errout.adb: New Finalize/Compilation_Errors/Output_Messages
	implementation

	* errout.ads (Finalize): Changed interface
	(Output_Messages): New procedure
	(Compilation_Errors): New Interface

	* prepcomp.ads, prepcomp.adb (Parse_Preprocessing_Data_File): New
	Finalize/Output_Messages interface for Errout
	(Prepare_To_Preprocess): New Finalize/Output_Messages interface for
	Errout.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]