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] New switch -gnatL


Tested on i686-linux, committed on trunk.

This patch implements a new switch -gnatL which causes expanded source
output from the use of -gnatG or -gnatD to be interspersed with the
original source lines. A subsidiary change to make this output look
better fixes Write_Condition_And_Reason to use multiple lines if there
is a complicated condition present.

The following program is used as an example:

-- this is the package
-- spec of package p
package p is
   procedure q;
   x : Integer;
private
   y : integer;
end p;

package body p is
   S : String (1 .. 10);
   J : Integer range 1 .. 10;

   procedure q is
   begin
      null;
   end;
begin
   x := 3;
   y := 4;
   J := J + 1;
   S (1 .. J) := S (2 .. J + 1);
end;

The output when compiled with -gnatGL is:

Source recreated from tree for p (body)
---------------------------------------

-- 1: package body p is
package body p is

-- 2:    S : String (1 .. 10);
   subtype p__TsS is string (1 .. 10);
   p__s : string (1 .. 10);

-- 3:    J : Integer range 1 .. 10;
   subtype p__TjS is integer range 1 .. 10;
   p__j : integer range 1 .. 10;

-- 4:

-- 5:    procedure q is
   procedure p__q is

-- 6:    begin
   begin

-- 7:       null;
      null;

-- 8:    end;
      return;
   end p__q;

-- 9: begin
begin

-- 10:    x := 3;
   p__x := 3;

-- 11:    y := 4;
   p__y := 4;

-- 12:    J := J + 1;
   p__R1b : constant integer := p__j + 1;
   [constraint_error when
     not (p__R1b in 1 .. 10)
     "range check failed"]
   p__j := p__R1b;

-- 13:    S (1 .. J) := S (2 .. J + 1);
   [constraint_error when
     integer(p__j) > 10
     "range check failed"]
   p__R2b : constant p__TjS := p__j;
   [constraint_error when
     p__j + 1 >= 2 and then (p__j + 1 > 10)
     "range check failed"]
   p__R5b : constant integer := p__j + 1;
   [subtype p__T3b is integer range 1 .. p__R2b]
   [subtype p__T4b is string (p__T3b)]
   reference p__T4b
   [subtype p__T6b is integer range 2 .. p__R5b]
   [subtype p__T7b is string (p__T6b)]
   reference p__T7b
   [constraint_error when
     p__T4b'length /= p__T7b'length
     "length check failed"]
   reference p__T4b
   reference p__T7b
   p__s ({1 .. p__R2b}) := p__s ({2 .. p__R5b});

-- 14: end;
end p;

Source recreated from tree for p (spec)
---------------------------------------

-- 1: -- this is the package
-- 2: -- spec of package p

-- 3: package p is
p_E : boolean := false;
package p is

-- 4:    procedure q;
   procedure p__q;

-- 5:    x : Integer;
   p__x : integer;

-- 6: private
private

-- 7:    y : integer;
   p__y : integer;

-- 8: end p;
end p;

In addition, this change adds some circuitry for the case of a modular subtype
itype whose base type is private. Previously, we unconditionally tried to
retrieve the bounds of the base type, which is incorrect when it is
private.

See gnat.dg/gnatg.adb

2006-10-31  Ed Schonberg  <schonberg@adacore.com>
	    Robert Dewar  <dewar@adacore.com>
	    Bob Duff  <duff@adacore.com>

	* sprint.adb (Sprint_Node_Actual, case Parameter_Specification): Do not
	print null exclusion twice in the case of an access definition,
	Implement new -gnatL switch
	Remove N_Return_Object_Declaration. We now use
	N_Object_Declaration instead. Implement the case for
	N_Extended_Return_Statement. Alphabetize the cases.
	Add cases for new nodes N_Extended_Return_Statement and
	N_Return_Object_Declaration. The code is not yet written.
	Update the output for N_Formal_Object_Declaration
	and N_Object_Renaming_Declaration.
	(Write_Itype): Account for the case of a modular integer subtype whose
	base type is private.

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]