This patch changes the formatting of errors related to the pragma Extensions_Visible so as not to suggest Extensions_Visible applies to a formal parameters instead of a subprogram when SPARK RM 6.1.7(3) is violated. In addition, a small change to sem_prag was made to make the printing of boolean values consistent accross all error messages.
------------ -- Source -- ------------ -- ext_vis_error.ads package Ext_Vis_Error with SPARK_Mode is type Root is tagged record Comp_1 : Integer := 1; end record; type Child is new Root with record Comp_2 : Integer := 2; end record; procedure Proc_1 (Obj_C : Child) with Extensions_Visible => False; procedure Proc_2 (Obj_C : Child) with Extensions_Visible => True; end Ext_Vis_Error; -- ext_vis_error.adb package body Ext_Vis_Error with SPARK_Mode is procedure Proc_1 (Obj_C : Child) is Error_1 : constant Root'Class := Obj_C; Error_2 : constant Root'Class := Root'Class (Obj_C); begin Proc_2 (Obj_C); end Proc_1; procedure Proc_2 (Obj_C : Child) is begin null; end Proc_2; end Ext_Vis_Error; ---------------------------- -- Compilation and output -- ---------------------------- gcc -c ext_vis_error.adb gcc -c ext_vis_error.adb -gnatd.F ext_vis_error.adb:3:40: formal parameter cannot be implicitly converted to class-wide type when Extensions_Visible is False ext_vis_error.adb:4:52: formal parameter cannot be converted to class-wide type when Extensions_Visible is False ext_vis_error.adb:7:15: formal parameter cannot act as actual parameter when Extensions_Visible is False ext_vis_error.adb:7:15: subprogram "Proc_2" has Extensions_Visible True ext_vis_error.adb:3:40: formal parameter cannot be implicitly converted to class-wide type when Extensions_Visible is False ext_vis_error.adb:4:52: formal parameter cannot be converted to class-wide type when Extensions_Visible is False ext_vis_error.adb:7:15: formal parameter cannot act as actual parameter when Extensions_Visible is False ext_vis_error.adb:7:15: subprogram "Proc_2" has Extensions_Visible True Tested on x86_64-pc-linux-gnu, committed on trunk 2016-06-14 Justin Squirek <squi...@adacore.com> * sem_ch3.adb (Analyze_Object_Declaration): Fix formatting of error output related to SPARK RM 6.1.7(3) and pragma Extensions_Visible. * sem_ch4.adb (Analyze_Type_Conversion): Fix formatting of error output related to SPARK RM 6.1.7(3) and pragma Extensions_Visible. * sem_prag.adb (Analyze_Pragma): Fix formatting of error output related to SPARK RM 7.1.2(15) and pragma Volatile_Function so that the values True and False are no longer surrounded by double quotes. * sem_res.adb (Resolve_Actuals): Fix formatting of error output related to SPARK RM 6.1.7(3) and pragma Extensions_Visible.
Index: sem_ch3.adb =================================================================== --- sem_ch3.adb (revision 237429) +++ sem_ch3.adb (working copy) @@ -3796,8 +3796,8 @@ and then Is_EVF_Expression (E) then Error_Msg_N - ("formal parameter with Extensions_Visible False cannot be " - & "implicitly converted to class-wide type", E); + ("formal parameter cannot be implicitly converted to " + & "class-wide type when Extensions_Visible is False", E); end if; end if; Index: sem_prag.adb =================================================================== --- sem_prag.adb (revision 237429) +++ sem_prag.adb (working copy) @@ -22821,12 +22821,12 @@ Error_Msg_Sloc := Sloc (Over_Id); Error_Msg_N - ("\& declared # with Volatile_Function value `False`", + ("\& declared # with Volatile_Function value False", Spec_Id); Error_Msg_Sloc := Sloc (Spec_Id); Error_Msg_N - ("\overridden # with Volatile_Function value `True`", + ("\overridden # with Volatile_Function value True", Spec_Id); end if; Index: sem_res.adb =================================================================== --- sem_res.adb (revision 237432) +++ sem_res.adb (working copy) @@ -4596,8 +4596,8 @@ Extensions_Visible_True then Error_Msg_N - ("formal parameter with Extensions_Visible False cannot act " - & "as actual parameter", A); + ("formal parameter cannot act as actual parameter when " + & "Extensions_Visible is False", A); Error_Msg_NE ("\subprogram & has Extensions_Visible True", A, Nam); end if; Index: sem_ch4.adb =================================================================== --- sem_ch4.adb (revision 237429) +++ sem_ch4.adb (working copy) @@ -5246,8 +5246,8 @@ and then Is_EVF_Expression (Expr) then Error_Msg_N - ("formal parameter with Extensions_Visible False cannot be " - & "converted to class-wide type", Expr); + ("formal parameter cannot be converted to class-wide type when " + & "Extensions_Visible is False", Expr); end if; end Analyze_Type_Conversion;