From 184a23e94a1b968a1b94defad02a00479a3264a2 Mon Sep 17 00:00:00 2001 From: Hristian Kirtchev Date: Mon, 2 Mar 2015 10:52:59 +0000 Subject: [PATCH] exp_util.adb (Possible_Bit_Aligned_Component): Do not process an unanalyzed node. 2015-03-02 Hristian Kirtchev * exp_util.adb (Possible_Bit_Aligned_Component): Do not process an unanalyzed node. * sem_util.adb (Kill_Current_Values): Do not invalidate and de-null a constant. From-SVN: r221107 --- gcc/ada/ChangeLog | 7 +++++++ gcc/ada/exp_util.adb | 7 +++++++ gcc/ada/sem_util.adb | 35 ++++++++++++++++++++++++----------- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ca3de2d8f43..6220a7ed89b 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2015-03-02 Hristian Kirtchev + + * exp_util.adb (Possible_Bit_Aligned_Component): Do not process + an unanalyzed node. + * sem_util.adb (Kill_Current_Values): Do not invalidate and + de-null a constant. + 2015-03-02 Robert Dewar * sem_ch3.adb, exp_attr.adb, checks.adb, exp_aggr.adb: Minor diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index aa835adf632..a565e7f023b 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -6938,6 +6938,13 @@ package body Exp_Util is function Possible_Bit_Aligned_Component (N : Node_Id) return Boolean is begin + -- Do not process an unanalyzed node because it is not yet decorated and + -- most checks performed below will fail. + + if not Analyzed (N) then + return False; + end if; + case Nkind (N) is -- Case of indexed component diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index d9ab705bd13..2ea04d700b9 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -13012,20 +13012,33 @@ package body Sem_Util is Kill_Checks (Ent); Set_Current_Value (Ent, Empty); - if not Can_Never_Be_Null (Ent) then - Set_Is_Known_Non_Null (Ent, False); - end if; + -- Do not reset the Is_Known_[Non_]Null and Is_Known_Valid flags + -- for a constant. Once the constant is elaborated, its value is + -- not changed, therefore the associated flags that describe the + -- value should not be modified either. - Set_Is_Known_Null (Ent, False); + if Ekind (Ent) = E_Constant then + null; - -- Reset Is_Known_Valid unless type is always valid, or if we have - -- a loop parameter (loop parameters are always valid, since their - -- bounds are defined by the bounds given in the loop header). + -- Non-constant entities - if not Is_Known_Valid (Etype (Ent)) - and then Ekind (Ent) /= E_Loop_Parameter - then - Set_Is_Known_Valid (Ent, False); + else + if not Can_Never_Be_Null (Ent) then + Set_Is_Known_Non_Null (Ent, False); + end if; + + Set_Is_Known_Null (Ent, False); + + -- Reset the Is_Known_Valid flag unless the type is always + -- valid. This does not apply to a loop parameter because its + -- bounds are defined by the loop header and therefore always + -- valid. + + if not Is_Known_Valid (Etype (Ent)) + and then Ekind (Ent) /= E_Loop_Parameter + then + Set_Is_Known_Valid (Ent, False); + end if; end if; end if; end if; -- 2.30.2