From: Arnaud Charlet Date: Wed, 19 Feb 2014 10:51:26 +0000 (+0100) Subject: [multiple changes] X-Git-Tag: releases/gcc-4.9.0~857 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f660fba6af9ac165d3e02c0a9083c9e0897e0c52;p=thirdparty%2Fgcc.git [multiple changes] 2014-02-19 Hristian Kirtchev * sem_prag.adb (Check_Refined_Global_Item): A state or variable acts as a constituent only it is part of an encapsulating state and the state has visible refinement. 2014-02-19 Ed Schonberg * sem_ch6.adb (Analyze_Subprogram_Contract): Do not warn on a postcondition for a function when the expression does not mention 'Result but the function has in-out parameters. 2014-02-19 Robert Dewar * gnat_rm.texi: Add documentation on Value_Size forcing biased representation. From-SVN: r207886 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 95f2ac33e86c..9df54e5dea79 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,20 @@ +2014-02-19 Hristian Kirtchev + + * sem_prag.adb (Check_Refined_Global_Item): + A state or variable acts as a constituent only it is part of an + encapsulating state and the state has visible refinement. + +2014-02-19 Ed Schonberg + + * sem_ch6.adb (Analyze_Subprogram_Contract): Do not warn on a + postcondition for a function when the expression does not mention + 'Result but the function has in-out parameters. + +2014-02-19 Robert Dewar + + * gnat_rm.texi: Add documentation on Value_Size forcing biased + representation. + 2014-02-19 Hristian Kirtchev * lib-xref.ads Remove the small table of letter and symbol usage as we diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index dad15cd919ca..6453c28c1b1d 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -14262,6 +14262,34 @@ For all other types, the @code{Object_Size} and Value_Size are the same (and equivalent to the RM attribute @code{Size}). Only @code{Size} may be specified for such types. +Note that @code{Value_Size} can be used to force biased representation +for a particular subtype. Consider this example: + +@smallexample + type R is (A, B, C, D, E, F); + subtype RAB is R range A .. B; + subtype REF is R range E .. F; +@end smallexample + +@noindent +By default, @code{RAB} +has a size of 1 (sufficient to accomodate the representation +of @code{A} and @code{B}, 0 and 1), and @code{REF} +has a size of 3 (sufficient to accomodate the representation +of @code{E} and @code{F}, 4 and 5). But if we add the +following @code{Value_Size} attribute definition clause: + +@smallexample + for REF'Value_Size use 1; +@end smallexample + +@noindent +then biased representation is forced for @code{REF}, +and 0 will represent @code{E} and 1 will represent @code{F}. +A warning is issued when a @code{Value_Size} attribute +definition clause forces biased representation. This +warning can be turned off using @code{-gnatw.B}. + @node Component_Size Clauses @section Component_Size Clauses @cindex Component_Size Clause diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index fa2722bc0dad..5231dfde7b14 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -3663,7 +3663,25 @@ package body Sem_Ch6 is Error_Msg_N ("contract cases do not mention result?T?", Case_Prag); + -- OK if we have at least one IN OUT parameter + elsif Present (Post_Prag) and then not Seen_In_Post then + declare + F : Entity_Id; + begin + F := First_Formal (Subp); + while Present (F) loop + if Ekind (F) = E_In_Out_Parameter then + return; + else + Next_Formal (F); + end if; + end loop; + end; + + -- If no in-out parameters and no mention of Result, the contract + -- is certainly suspicious. + Error_Msg_N ("function postcondition does not mention result?T?", Post_Prag); end if; diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 5357230e7d63..723ac3b1adbb 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -22610,10 +22610,13 @@ package body Sem_Prag is -- Start of processing for Check_Refined_Global_Item begin - -- The state or variable acts as a constituent of a state, collect - -- it for the state completeness checks performed later on. + -- When the state or variable acts as a constituent of another + -- state with a visible refinement, collect it for the state + -- completeness checks performed later on. - if Present (Encapsulating_State (Item_Id)) then + if Present (Encapsulating_State (Item_Id)) + and then Has_Visible_Refinement (Encapsulating_State (Item_Id)) + then if Global_Mode = Name_Input then Add_Item (Item_Id, In_Constits);