]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Fix inconsistent handling of character set control switches
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 1 Jan 2021 23:51:21 +0000 (00:51 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 4 May 2021 09:17:29 +0000 (05:17 -0400)
gcc/ada/

* csets.adb (Initialize): Refactor into CASE statement; raise
exception on unsupported code of character set (it will be
gently rejected earlier when scanning command line switches).
* switch-b.adb (Scan_Binder_Switches): Refactor into a
membership expression; add missing '9' choice; reorder as
described by GNAT UG, section 4.3.11.
* switch-c.adb (Scan_Front_End_Switches): Refactor into a
membership expression and reorder as above.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst
(gnatic): Mention '5' as an allowed value for "c".
* gnat_ugn.texi: Regenerate.

gcc/ada/csets.adb
gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst
gcc/ada/gnat_ugn.texi
gcc/ada/switch-b.adb
gcc/ada/switch-c.adb

index 1961fcd5f03452e4d9a32cc4fc53b0b2bd7ef828..29a15920998f4ba8176cc060ad779bfef825964c 100644 (file)
@@ -1091,38 +1091,40 @@ package body Csets is
    begin
       --  Set Fold_Upper table from source code indication
 
-      if Identifier_Character_Set = '1'
-        or else Identifier_Character_Set = 'w'
-      then
-         Fold_Upper := Fold_Latin_1;
+      case Identifier_Character_Set is
+         when '1' | 'w' =>
+            Fold_Upper := Fold_Latin_1;
 
-      elsif Identifier_Character_Set = '2' then
-         Fold_Upper := Fold_Latin_2;
+         when '2' =>
+            Fold_Upper := Fold_Latin_2;
 
-      elsif Identifier_Character_Set = '3' then
-         Fold_Upper := Fold_Latin_3;
+         when '3' =>
+            Fold_Upper := Fold_Latin_3;
 
-      elsif Identifier_Character_Set = '4' then
-         Fold_Upper := Fold_Latin_4;
+         when '4' =>
+            Fold_Upper := Fold_Latin_4;
 
-      elsif Identifier_Character_Set = '5' then
-         Fold_Upper := Fold_Cyrillic;
+         when '5' =>
+            Fold_Upper := Fold_Cyrillic;
 
-      elsif Identifier_Character_Set = 'p' then
-         Fold_Upper := Fold_IBM_PC_437;
+         when '9' =>
+            Fold_Upper := Fold_Latin_9;
 
-      elsif Identifier_Character_Set = '8' then
-         Fold_Upper := Fold_IBM_PC_850;
+         when 'p' =>
+            Fold_Upper := Fold_IBM_PC_437;
 
-      elsif Identifier_Character_Set = '9' then
-         Fold_Upper := Fold_Latin_9;
+         when '8' =>
+            Fold_Upper := Fold_IBM_PC_850;
 
-      elsif Identifier_Character_Set = 'f' then
-         Fold_Upper := Fold_Full_Upper_Half;
+         when 'f' =>
+            Fold_Upper := Fold_Full_Upper_Half;
 
-      else -- Identifier_Character_Set = 'n'
-         Fold_Upper := Fold_No_Upper_Half;
-      end if;
+         when 'n' =>
+            Fold_Upper := Fold_No_Upper_Half;
+
+         when others =>
+            raise Program_Error;
+      end case;
 
       --  Use Fold_Upper table to compute Fold_Lower table
 
index 82e992a5041440d49a3f8d21f4dd2ace53b60ce3..91fae31c4e89ed1e86f7d52de375e1934c01bf8a 100644 (file)
@@ -1896,7 +1896,7 @@ Alphabetical List of All Switches
 .. index:: -gnati  (gcc)
 
 :switch:`-gnati{c}`
-  Identifier character set (``c`` = 1/2/3/4/8/9/p/f/n/w).
+  Identifier character set (``c`` = 1/2/3/4/5/9/p/8/f/n/w).
   For details of the possible selections for ``c``,
   see :ref:`Character_Set_Control`.
 
index ae8f758035530ed8ef0151dbc80fb43c12b33e6d..559231415d496c2af54219e579c2571c42190443 100644 (file)
@@ -21,7 +21,7 @@
 
 @copying
 @quotation
-GNAT User's Guide for Native Platforms , Dec 11, 2020
+GNAT User's Guide for Native Platforms , Apr 12, 2021
 
 AdaCore
 
@@ -9462,7 +9462,7 @@ For further details see @ref{f,,Elaboration Order Handling in GNAT}.
 
 @item @code{-gnati@emph{c}}
 
-Identifier character set (@code{c} = 1/2/3/4/8/9/p/f/n/w).
+Identifier character set (@code{c} = 1/2/3/4/5/9/p/8/f/n/w).
 For details of the possible selections for @code{c},
 see @ref{31,,Character Set Control}.
 @end table
index 012f4eed3d4c3023fbe677c54efdf1c94589ccc4..a7359789e5aa156e03d7a2ae9a49d04cfd765921 100644 (file)
@@ -369,13 +369,7 @@ package body Switch.B is
             Ptr := Ptr + 1;
             C := Switch_Chars (Ptr);
 
-            if C in '1' .. '5'
-              or else C = '8'
-              or else C = 'p'
-              or else C = 'f'
-              or else C = 'n'
-              or else C = 'w'
-            then
+            if C in '1' .. '5' | '9' | 'p' | '8' | 'f' | 'n' | 'w' then
                Identifier_Character_Set := C;
                Ptr := Ptr + 1;
             else
index ff6c81a6cf1bfefa20856d1f8b4cd1a1c18d431d..b97e0d6e55389f976f1ae9b5c25dd2df7112587b 100644 (file)
@@ -929,14 +929,7 @@ package body Switch.C is
                Ptr := Ptr + 1;
                C := Switch_Chars (Ptr);
 
-               if C in '1' .. '5'
-                 or else C = '8'
-                 or else C = '9'
-                 or else C = 'p'
-                 or else C = 'f'
-                 or else C = 'n'
-                 or else C = 'w'
-               then
+               if C in '1' .. '5' | '8' | 'p' | '9' | 'f' | 'n' | 'w' then
                   Identifier_Character_Set := C;
                   Ptr := Ptr + 1;