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 handling of preprocessor


Tested on i686-linux, committed on trunk

When the compiler is invoked with preprocessing and there are
preprocessing errors in the main source, the compiler may crash. This
patch ensures that it does not crash and that the errors are displayed.

Compiling the following source main.adb:

#if HOST then
with Ada.Text_IO;
#end if;
procedure Main is
begin
   null;
end;

with the command
$ gcc -c -gnateDTOTO main.adb
should produce the following errors:

main.adb:1:01: file could not be successfully preprocessed
main.adb:1:05: unknown symbol "Host"

This change also improves an error reporting circuitry for cases of bugs
in the GNAT runtime library.

When a bogus version of System.Partition_Interface (given below)
is present in the current directory, compilation of rt.ads must
provide a 'run-time library configuration error' message and mention
errors in s-parint.ads.

$ gcc -c rt.ads
s-parint.ads:3:04: declaration expected
s-parint.ads:5:11: run-time library configuration error
s-parint.ads:5:11: file s-parint.ads had parser errors
compilation abandoned due to previous error

package RT is
   pragma Remote_Types;
   type O is abstract tagged limited private;
   type RACW is access all O'Class;
private
   type O is abstract tagged limited null record;
end RT;
package System.Partition_Interface is

   BOGUS-PACKAGE-WITH-A-SYNTAX-ERROR

end System.Partition_Interface;

This patch implements an informational output message if an attempt
is made to generate representation information when no code is
generated.

For example, given the sources:

procedure P is
   procedure Q is separate;
begin
   null;
end P;

separate (P)
procedure Q is
   type T is record
      I : Integer;
   end record;
begin
   null;
end Q;

A compilation using the command

gcc -c p-q.adb -gnatR -gnatc

generates the output:

cannot generate representation information, no code generated

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

	* frontend.adb (Frontend): Return immediately if the main source could
	not be parsed, because of preprocessing errors.

	* gnat1drv.adb (gnat1drv): Handle RE_Not_Available gracefully.
	(Gnat1drv): Exit with errors if the main source could not be parsed,
	because of preprocessing errors.
	(Check_Rep_Info): New procedure

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]