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 bug in handling of itypes


Tested on i686-linux, committed on trunk

This patch fixes bugs in the handling of itypes in expressions that are being
copied. In some situations, when a hash-table is being used to link old itypes
to new ones and to their associated nodes, entries were not being made when
the hash table was created in the middle of performing a copy. In addition,
the itypes created for index types in aggregates used the aggregate itself as
an associated node, and in some cases prevented the itype of the array type
itself from being properly updated.

gnat.dg/itypes.adb must compile quietly.

Also, prior to this patch, the tree could only represent three
levels of nested parentheses around a single subexpression.
This had three consequences:

Failure to detect pathological cases of non-conformance
(see test below).

Failure to represent more than three levels of parens
in -gnatG output

Really bad chaos in gnatpp when more than three levels
of parens present.

This patch fixes the problem by introducing an auxiliary
table in atree.adb to represent the cases of 3 or more
parens, and fixing Set_Paren_Count and Paren_Count to use
this table.

Two other related changes are to adjust the copy node
functions in atree to properly update the table, and
remove the par-ch4.adb kludge to max out at 3 paren
levels.

Given the following test source:

procedure w is
   procedure x (a : integer := (1));
   procedure x (a : integer := ((1))) is
   begin
      null;
   end;

   procedure y (a : integer := ((((1)))));
   procedure y (a : integer := (((((1)))))) is
   begin
      null;
   end;
begin
   null;
end;

compiling now generates two sets of error messages:

     1. procedure w is
     2.    procedure x (a : integer := (1));
     3.    procedure x (a : integer := ((1))) is
                     |
        >>> not fully conformant with declaration at line 2
        >>> default expression for "a" does not match

     4.    begin
     5.       null;
     6.    end;
     7.
     8.    procedure y (a : integer := ((((1)))));
     9.    procedure y (a : integer := (((((1)))))) is
                     |
        >>> not fully conformant with declaration at line 8
        >>> default expression for "a" does not match

    10.    begin
    11.       null;
    12.    end;
    13. begin
    14.    null;
    15. end;

and compiling with -gnatG generates:

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


procedure w is
   procedure x (a : integer := (1));

   procedure x (a : integer := ((1))) is
   begin
      null;
   end x;

   procedure y (a : integer := ((((1)))));

   procedure y (a : integer := (((((1)))))) is
   begin
      null;
   end y;
begin
   null;
end w;

Finally, when a component of an aggregate has a box association, and the type
of the component is discriminated and has no initialization procedure, we build
an aggregate for the components using the values of the discriminants in the
discriminant constraints of the type, and an others box association for the
remaining components. If there are no other components the others association
should not be generated.

gnat.dg/modify_a_constant.adb must compile quietly.

2007-08-14  Ed Schonberg  <schonberg@adacore.com>
	    Robert Dewar  <dewar@adacore.com>

	* atree.ads, atree.adb (New_Copy_Tree): If hash table is being used and
	itype is visited, make an entry into table to link associated node and
	new itype.
	Add comments and correct harmless error in Build_NCT_Hash_Tables
	(Array_Aggr_Subtype): Associate each itype created for an index type to
	the corresponding range construct, and not to the aggregate itself. to
	maintain a one-to-one correspondence between itype and its associated
	node, to prevent errors when complex expression is copied.
	Fix mishandling of multiple levels of parens

	* sem_aggr.adb: Create a limited view of an incomplete type, to make
	treatment of limited views uniform for all visible declarations in a
	limited_withed package.
	(New_Copy_Tree): If hash table is being used and itype is visited,
	make an entry into table to link associated node and new itype.
	(Resolve_Record_Aggregate): Do not add an others box association for a
	discriminated record component that has only discriminants, when there
	is a box association for the component itself.

	* par-ch4.adb: Fix mishandling of multiple levels of parens

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]