Ongoing work to implement AI05-0144. Tested on x86_64-pc-linux-gnu, committed on trunk
2013-01-03 Javier Miranda <mira...@adacore.com> * sem_warn.adb (Warn_On_Overlapping_Actuals): For overlapping parameters that are record types or array types generate warnings only compiling under -gnatw.i * opt.ads (Extensions_Allowed): Restore previous documentation.
Index: sem_warn.adb =================================================================== --- sem_warn.adb (revision 194848) +++ sem_warn.adb (working copy) @@ -3293,8 +3293,7 @@ Form1, Form2 : Entity_Id; function Is_Covered_Formal (Formal : Node_Id) return Boolean; - -- Return True if Formal is covered by the Ada 2012 rule. Under -gnatX - -- the rule is extended to cover record and array types. + -- Return True if Formal is covered by the rule. function Refer_Same_Object (Act1, Act2 : Node_Id) return Boolean; -- Two names are known to refer to the same object if the two names @@ -3321,24 +3320,12 @@ function Is_Covered_Formal (Formal : Node_Id) return Boolean is begin - -- Ada 2012 rule - - if not Extensions_Allowed then - return - Ekind_In (Formal, E_Out_Parameter, - E_In_Out_Parameter) - and then Is_Elementary_Type (Etype (Formal)); - - -- Under -gnatX the rule is extended to cover array and record types - - else - return - Ekind_In (Formal, E_Out_Parameter, - E_In_Out_Parameter) - and then (Is_Elementary_Type (Etype (Formal)) - or else Is_Record_Type (Etype (Formal)) - or else Is_Array_Type (Etype (Formal))); - end if; + return + Ekind_In (Formal, E_Out_Parameter, + E_In_Out_Parameter) + and then (Is_Elementary_Type (Etype (Formal)) + or else Is_Record_Type (Etype (Formal)) + or else Is_Array_Type (Etype (Formal))); end Is_Covered_Formal; begin @@ -3360,7 +3347,8 @@ -- there is no other name among the other parameters of mode in out or -- out to C that is known to denote the same object (RM 6.4.1(6.15/3)) - -- Under -gnatX the rule is extended to cover array and record types. + -- Compiling under -gnatw.i we also report warnings on overlapping + -- parameters that are record types or array types. Form1 := First_Formal (Subp); Act1 := First_Actual (N); @@ -3401,10 +3389,21 @@ then null; + -- Under Ada 2012 we only report warnings on overlapping + -- arrays and record types if compiling under -gnatw.i + + elsif Ada_Version >= Ada_2012 + and then not Is_Elementary_Type (Etype (Form1)) + and then not Warn_On_Overlap + then + null; + -- Here we may need to issue message else - Error_Msg_Warn := Ada_Version < Ada_2012; + Error_Msg_Warn := + Ada_Version < Ada_2012 + or else not Is_Elementary_Type (Etype (Form1)); declare Act : Node_Id; Index: opt.ads =================================================================== --- opt.ads (revision 194848) +++ opt.ads (working copy) @@ -563,7 +563,7 @@ Extensions_Allowed : Boolean := False; -- GNAT -- Set to True by switch -gnatX if GNAT specific language extensions - -- are allowed. + -- are allowed. Currently there are no such defined extensions. type External_Casing_Type is ( As_Is, -- External names cased as they appear in the Ada source