[Ada] Crash on aggregate with discriminant expanded name in default expression

Arnaud Charlet charlet@adacore.com
Tue Jun 22 16:52:00 GMT 2010


This change fixes a compiler crash in the processing of aggregates with
boxes, in the case where some default expression contains a reference
to a discriminant of the type written as an expanded name rather than
an identifier.

The following compilation must be accepted quietly:

$ gcc -c exp_name_discr_in_default.adb
pragma Ada_2005;
procedure Exp_Name_Discr_In_Default is
   type Rule_Tracker (Size : Positive) is record
      Still_Active : Natural := Rule_Tracker.Size;
   end record;
   Tracker_Size : constant Positive := 1234;
   procedure P (X : Rule_Tracker) is begin null; end;
begin
   P ((Size => Tracker_Size, others => <>));
end Exp_Name_Discr_In_Default;

Tested on x86_64-pc-linux-gnu, committed on trunk

2010-06-22  Thomas Quinot  <quinot@adacore.com>

	* exp_aggr.adb (Rewrite_Discriminant): Fix predicate used to identify
	reference to discriminant (can be an expanded name as well as an
	identifier).

-------------- next part --------------
Index: exp_aggr.adb
===================================================================
--- exp_aggr.adb	(revision 161195)
+++ exp_aggr.adb	(working copy)
@@ -2427,7 +2427,7 @@ package body Exp_Aggr is
 
       function Rewrite_Discriminant (Expr : Node_Id) return Traverse_Result is
       begin
-         if Nkind (Expr) = N_Identifier
+         if Is_Entity_Name (Expr)
            and then Present (Entity (Expr))
            and then Ekind (Entity (Expr)) = E_In_Parameter
            and then Present (Discriminal_Link (Entity (Expr)))


More information about the Gcc-patches mailing list