From: Piotr Trojanek Date: Fri, 3 Apr 2020 09:36:55 +0000 (+0200) Subject: [Ada] Accept renamings of folded string aggregates X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d7769a80a8ca67be548ad926c81b8a23eedfc3ea;p=gcc.git [Ada] Accept renamings of folded string aggregates 2020-06-16 Piotr Trojanek gcc/ada/ * sem_ch8.adb (Analyze_Object_Renaming): Remove trivially useless initialization of Is_Object_Reference. * sem_util.adb (Is_Object_Reference): Simplify detection of binary and unary operators; literally implement rules about aggregates and qualified expressions; recognize string literals as object references. --- diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index b9e599046b2..069341c0dcb 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -754,7 +754,7 @@ package body Sem_Ch8 is Id : constant Entity_Id := Defining_Identifier (N); Loc : constant Source_Ptr := Sloc (N); Nam : constant Node_Id := Name (N); - Is_Object_Ref : Boolean := False; + Is_Object_Ref : Boolean; Dec : Node_Id; T : Entity_Id; T2 : Entity_Id; @@ -1366,7 +1366,7 @@ package body Sem_Ch8 is if T = Any_Type or else Etype (Nam) = Any_Type then return; - -- Verify that the renamed entity is an object or function call. + -- Verify that the renamed entity is an object or function call elsif Is_Object_Ref then if Comes_From_Source (N) then diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index a3dbaaf34fa..dd9ab2ea6d6 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -16978,9 +16978,8 @@ package body Sem_Util is -- Note that predefined operators are functions as well, and so -- are attributes that are (can be renamed as) functions. - when N_Binary_Op - | N_Function_Call - | N_Unary_Op + when N_Function_Call + | N_Op => return Etype (N) /= Standard_Void_Type; @@ -17040,12 +17039,21 @@ package body Sem_Util is -- of aggregates in more contexts. when N_Qualified_Expression => - if Ada_Version < Ada_2012 then - return False; - else - return Is_Object_Reference (Expression (N)) - or else Nkind (Expression (N)) = N_Aggregate; - end if; + return Ada_Version >= Ada_2012 + and then Is_Object_Reference (Expression (N)); + + -- In Ada 95 an aggreate is an object reference + + when N_Aggregate => + return Ada_Version >= Ada_95; + + -- A string literal is not an object reference, but it might come + -- from rewriting of an object reference, e.g. from folding of an + -- aggregate. + + when N_String_Literal => + return Is_Rewrite_Substitution (N) + and then Is_Object_Reference (Original_Node (N)); when others => return False;