From patchwork Tue Jun 22 16:23:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Ada] Crash on aggregate with discriminant expanded name in default expression Date: Tue, 22 Jun 2010 06:23:16 -0000 From: Arnaud Charlet X-Patchwork-Id: 56525 Message-Id: <20100622162316.GA25559@adacore.com> To: gcc-patches@gcc.gnu.org Cc: Thomas Quinot 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 * exp_aggr.adb (Rewrite_Discriminant): Fix predicate used to identify reference to discriminant (can be an expanded name as well as an identifier). 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)))