diff mbox

[Ada] Wrong casing of restriction and check names

Message ID 20170425094612.GA5882@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet April 25, 2017, 9:46 a.m. UTC
Fixes bugs in which the wrong casing was used for restriction names in
pragmas Restrictions and Restriction_Warnings, and check names in pragma
Check. No test is available -- too complicated to make it fail.

Tested on x86_64-pc-linux-gnu, committed on trunk

2017-04-25  Bob Duff  <duff@adacore.com>

	* sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings):
	Use Source_Index (Current_Sem_Unit) to find the correct casing.
	* exp_prag.adb (Expand_Pragma_Check): Use Source_Index
	(Current_Sem_Unit) to find the correct casing.
	* par.adb (Par): Null out Current_Source_File, to ensure that
	the above bugs won't rear their ugly heads again.
diff mbox

Patch

Index: exp_prag.adb
===================================================================
--- exp_prag.adb	(revision 247162)
+++ exp_prag.adb	(working copy)
@@ -33,6 +33,7 @@ 
 with Exp_Util; use Exp_Util;
 with Expander; use Expander;
 with Inline;   use Inline;
+with Lib;      use Lib;
 with Namet;    use Namet;
 with Nlists;   use Nlists;
 with Nmake;    use Nmake;
@@ -432,11 +433,12 @@ 
                   Add_Str_To_Name_Buffer ("failed invariant from ");
 
                --  For all other checks, the string is "xxx failed at yyy"
-               --  where xxx is the check name with current source file casing.
+               --  where xxx is the check name with appropriate casing.
 
                else
                   Get_Name_String (Nam);
-                  Set_Casing (Identifier_Casing (Current_Source_File));
+                  Set_Casing
+                    (Identifier_Casing (Source_Index (Current_Sem_Unit)));
                   Add_Str_To_Name_Buffer (" failed at ");
                end if;
 
Index: sem_prag.adb
===================================================================
--- sem_prag.adb	(revision 247165)
+++ sem_prag.adb	(working copy)
@@ -9416,7 +9416,8 @@ 
 
                         if Is_Bad_Spelling_Of (Chars (Expr), Name_Enter) then
                            Set_Casing
-                             (Identifier_Casing (Current_Source_File));
+                             (Identifier_Casing
+                               (Source_Index (Current_Sem_Unit)));
                            Error_Msg_String (1 .. Rnm'Length) :=
                              Name_Buffer (1 .. Name_Len);
                            Error_Msg_Strlen := Rnm'Length;
Index: par.adb
===================================================================
--- par.adb	(revision 247150)
+++ par.adb	(working copy)
@@ -1457,6 +1457,8 @@ 
    procedure Labl is separate;
    procedure Load is separate;
 
+   Result : List_Id := Empty_List;
+
 --  Start of processing for Par
 
 begin
@@ -1472,13 +1474,13 @@ 
       begin
          loop
             if Token = Tok_EOF then
-               Compiler_State := Analyzing;
-               return Pragmas;
+               Result := Pragmas;
+               exit;
 
             elsif Token /= Tok_Pragma then
                Error_Msg_SC ("only pragmas allowed in configuration file");
-               Compiler_State := Analyzing;
-               return Error_List;
+               Result := Error_List;
+               exit;
 
             else
                P_Node := P_Pragma;
@@ -1690,7 +1692,9 @@ 
 
       Restore_Opt_Config_Switches (Save_Config_Switches);
       Set_Comes_From_Source_Default (False);
-      Compiler_State := Analyzing;
-      return Empty_List;
    end if;
+
+   Compiler_State      := Analyzing;
+   Current_Source_File := No_Source_File;
+   return Result;
 end Par;