From: Arnaud Charlet Date: Fri, 30 Jan 2015 14:59:21 +0000 (+0100) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=48b0da2d24cfd3c918f85007e569f69ccd4cf1c4;p=gcc.git [multiple changes] 2015-01-30 Hristian Kirtchev * sem_attr.adb (Analyze_Attribute): Ensure that the check concerning Refined_Post takes precedence over the other cases. 2015-01-30 Gary Dismukes * sem_prag.adb: Minor typo fixes and reformatting. From-SVN: r220282 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 56b0c13de15..c703eb928c5 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2015-01-30 Hristian Kirtchev + + * sem_attr.adb (Analyze_Attribute): Ensure that + the check concerning Refined_Post takes precedence over the + other cases. + +2015-01-30 Gary Dismukes + + * sem_prag.adb: Minor typo fixes and reformatting. + 2015-01-30 Yannick Moy * sem_attr.adb: Code clean up. diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index cf1ff9c460d..36ee0d2a4ce 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -4572,6 +4572,32 @@ package body Sem_Attr is CS := Scope (CS); end loop; + -- Check the legality of attribute 'Old when it appears inside pragma + -- Refined_Post. These specialized checks are required only when code + -- generation is disabled. In the general case pragma Refined_Post is + -- transformed into pragma Check by Process_PPCs which in turn is + -- relocated to procedure _Postconditions. From then on the legality + -- of 'Old is determined as usual. + + if not Expander_Active and then In_Refined_Post then + Preanalyze_And_Resolve (P); + Check_References_In_Prefix (CS); + P_Type := Etype (P); + Set_Etype (N, P_Type); + + if Is_Limited_Type (P_Type) then + Error_Attr ("attribute % cannot apply to limited objects", P); + end if; + + if Is_Entity_Name (P) + and then Is_Constant_Object (Entity (P)) + then + Error_Msg_N + ("??attribute Old applied to constant has no effect", P); + end if; + + return; + -- A Contract_Cases, Postcondition or Test_Case pragma is in the -- process of being preanalyzed. Perform the semantic checks now -- before the pragma is relocated and/or expanded. @@ -4579,7 +4605,7 @@ package body Sem_Attr is -- For a generic subprogram, postconditions are preanalyzed as well -- for name capture, and still appear within an aspect spec. - if In_Spec_Expression or Inside_A_Generic then + elsif In_Spec_Expression or Inside_A_Generic then Prag := N; while Present (Prag) and then not Nkind_In (Prag, N_Aspect_Specification, @@ -4625,32 +4651,6 @@ package body Sem_Attr is end case; end if; - -- Check the legality of attribute 'Old when it appears inside pragma - -- Refined_Post. These specialized checks are required only when code - -- generation is disabled. In the general case pragma Refined_Post is - -- transformed into pragma Check by Process_PPCs which in turn is - -- relocated to procedure _Postconditions. From then on the legality - -- of 'Old is determined as usual. - - elsif not Expander_Active and then In_Refined_Post then - Preanalyze_And_Resolve (P); - Check_References_In_Prefix (CS); - P_Type := Etype (P); - Set_Etype (N, P_Type); - - if Is_Limited_Type (P_Type) then - Error_Attr ("attribute % cannot apply to limited objects", P); - end if; - - if Is_Entity_Name (P) - and then Is_Constant_Object (Entity (P)) - then - Error_Msg_N - ("??attribute Old applied to constant has no effect", P); - end if; - - return; - -- Body case, where we must be inside a generated _Postconditions -- procedure, or else the attribute use is definitely misplaced. The -- postcondition itself may have generated transient scopes, and is diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index acae793f17c..4a3bb2172c5 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2014, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2015, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -17846,8 +17846,8 @@ package body Sem_Prag is or else (Is_Generic_Type (Ent) and then Is_Derived_Type (Ent)) -- AI05-0028: The pragma applies to all composite types. Note - -- that we apply this binding intepretation to previous verions - -- of Ada so there is no Ada 2012 guard. Seems a reasonable + -- that we apply this binding interpretation to earlier versions + -- of Ada, so there is no Ada 2012 guard. Seems a reasonable -- choice since there are other compilers that do the same. or else Is_Composite_Type (Ent)