summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/switch-b.adb42
-rw-r--r--gcc/ada/switch.adb47
-rw-r--r--gcc/ada/switch.ads23
3 files changed, 54 insertions, 58 deletions
diff --git a/gcc/ada/switch-b.adb b/gcc/ada/switch-b.adb
index de69081a104..f5beb05c470 100644
--- a/gcc/ada/switch-b.adb
+++ b/gcc/ada/switch-b.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2001-2005 Free Software Foundation, Inc. --
+-- Copyright (C) 2001-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -45,7 +45,7 @@ package body Switch.B is
-- Skip past the initial character (must be the switch character)
if Ptr = Max then
- raise Bad_Switch;
+ Bad_Switch (C);
else
Ptr := Ptr + 1;
end if;
@@ -122,7 +122,7 @@ package body Switch.B is
then
Set_Debug_Flag (C);
else
- raise Bad_Switch;
+ Bad_Switch (C);
end if;
end loop;
@@ -132,7 +132,8 @@ package body Switch.B is
when 'D' =>
Ptr := Ptr + 1;
- Scan_Pos (Switch_Chars, Max, Ptr, Default_Sec_Stack_Size);
+ Scan_Pos
+ (Switch_Chars, Max, Ptr, Default_Sec_Stack_Size, C);
-- Processing for e switch
@@ -181,7 +182,7 @@ package body Switch.B is
when 'i' =>
if Ptr = Max then
- raise Bad_Switch;
+ Bad_Switch (C);
end if;
Ptr := Ptr + 1;
@@ -197,7 +198,7 @@ package body Switch.B is
Identifier_Character_Set := C;
Ptr := Ptr + 1;
else
- raise Bad_Switch;
+ Bad_Switch (C);
end if;
-- Processing for K switch
@@ -216,7 +217,7 @@ package body Switch.B is
when 'm' =>
Ptr := Ptr + 1;
- Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors);
+ Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors, C);
-- Processing for n switch
@@ -234,7 +235,7 @@ package body Switch.B is
Ptr := Ptr + 1;
if Output_File_Name_Present then
- raise Too_Many_Output_Files;
+ Osint.Fail ("duplicate -o switch");
else
Output_File_Name_Present := True;
@@ -282,7 +283,7 @@ package body Switch.B is
when 'T' =>
Ptr := Ptr + 1;
Time_Slice_Set := True;
- Scan_Nat (Switch_Chars, Max, Ptr, Time_Slice_Value);
+ Scan_Nat (Switch_Chars, Max, Ptr, Time_Slice_Value, C);
Time_Slice_Value := Time_Slice_Value * 1_000;
-- Processing for v switch
@@ -308,7 +309,7 @@ package body Switch.B is
Warning_Mode := Suppress;
when others =>
- raise Bad_Switch;
+ Bad_Switch (C);
end case;
Ptr := Ptr + 1;
@@ -324,7 +325,7 @@ package body Switch.B is
exit;
elsif J = WC_Encoding_Method'Last then
- raise Bad_Switch;
+ Bad_Switch (C);
end if;
end loop;
@@ -345,7 +346,7 @@ package body Switch.B is
when 'X' =>
Ptr := Ptr + 1;
- Scan_Pos (Switch_Chars, Max, Ptr, Default_Exit_Status);
+ Scan_Pos (Switch_Chars, Max, Ptr, Default_Exit_Status, C);
-- Processing for z switch
@@ -402,7 +403,7 @@ package body Switch.B is
RTS_Src_Path_Name := Src_Path_Name;
RTS_Lib_Path_Name := Lib_Path_Name;
- -- We can exit as there can not be another switch
+ -- We can exit as there cannot be another switch
-- after --RTS
exit;
@@ -429,22 +430,9 @@ package body Switch.B is
-- Anything else is an error (illegal switch character)
when others =>
- raise Bad_Switch;
+ Bad_Switch (C);
end case;
end loop;
-
- exception
- when Bad_Switch =>
- Osint.Fail ("invalid switch: ", (1 => C));
-
- when Bad_Switch_Value =>
- Osint.Fail ("numeric value out of range for switch: ", (1 => C));
-
- when Missing_Switch_Value =>
- Osint.Fail ("missing numeric value for switch: ", (1 => C));
-
- when Too_Many_Output_Files =>
- Osint.Fail ("duplicate -o switch");
end Scan_Binder_Switches;
end Switch.B;
diff --git a/gcc/ada/switch.adb b/gcc/ada/switch.adb
index c960b57883f..048678bd19f 100644
--- a/gcc/ada/switch.adb
+++ b/gcc/ada/switch.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -24,8 +24,19 @@
-- --
------------------------------------------------------------------------------
+with Osint;
+
package body Switch is
+ ----------------
+ -- Bad_Switch --
+ ----------------
+
+ procedure Bad_Switch (Switch : Character) is
+ begin
+ Osint.Fail ("invalid switch: ", (1 => Switch));
+ end Bad_Switch;
+
-------------------------
-- Is_Front_End_Switch --
-------------------------
@@ -61,24 +72,27 @@ package body Switch is
(Switch_Chars : String;
Max : Integer;
Ptr : in out Integer;
- Result : out Nat)
+ Result : out Nat;
+ Switch : Character)
is
begin
Result := 0;
if Ptr > Max or else Switch_Chars (Ptr) not in '0' .. '9' then
- raise Missing_Switch_Value;
+ Osint.Fail ("missing numeric value for switch: ", (1 => Switch));
+
+ else
+ while Ptr <= Max and then Switch_Chars (Ptr) in '0' .. '9' loop
+ Result := Result * 10 +
+ Character'Pos (Switch_Chars (Ptr)) - Character'Pos ('0');
+ Ptr := Ptr + 1;
+
+ if Result > Switch_Max_Value then
+ Osint.Fail
+ ("numeric value out of range for switch: ", (1 => Switch));
+ end if;
+ end loop;
end if;
-
- while Ptr <= Max and then Switch_Chars (Ptr) in '0' .. '9' loop
- Result := Result * 10 +
- Character'Pos (Switch_Chars (Ptr)) - Character'Pos ('0');
- Ptr := Ptr + 1;
-
- if Result > Switch_Max_Value then
- raise Bad_Switch_Value;
- end if;
- end loop;
end Scan_Nat;
--------------
@@ -89,15 +103,16 @@ package body Switch is
(Switch_Chars : String;
Max : Integer;
Ptr : in out Integer;
- Result : out Pos)
+ Result : out Pos;
+ Switch : Character)
is
Temp : Nat;
begin
- Scan_Nat (Switch_Chars, Max, Ptr, Temp);
+ Scan_Nat (Switch_Chars, Max, Ptr, Temp, Switch);
if Temp = 0 then
- raise Bad_Switch_Value;
+ Osint.Fail ("numeric value out of range for switch: ", (1 => Switch));
end if;
Result := Temp;
diff --git a/gcc/ada/switch.ads b/gcc/ada/switch.ads
index 2be39a3f9e5..15c273f829c 100644
--- a/gcc/ada/switch.ads
+++ b/gcc/ada/switch.ads
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2003 Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2005 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -62,18 +62,6 @@ private
-- child packages (there is one such child package for each tool that
-- uses Switches to scan switches - Compiler/gnatbind/gnatmake/.
- Bad_Switch : exception;
- -- Exception raised if bad switch encountered
-
- Bad_Switch_Value : exception;
- -- Exception raised if bad switch value encountered
-
- Missing_Switch_Value : exception;
- -- Exception raised if no switch value encountered
-
- Too_Many_Output_Files : exception;
- -- Exception raised if the -o switch is encountered more than once
-
Switch_Max_Value : constant := 999_999;
-- Maximum value permitted in switches that take a value
@@ -81,7 +69,8 @@ private
(Switch_Chars : String;
Max : Integer;
Ptr : in out Integer;
- Result : out Nat);
+ Result : out Nat;
+ Switch : Character);
-- Scan natural integer parameter for switch. On entry, Ptr points
-- just past the switch character, on exit it points past the last
-- digit of the integer value.
@@ -90,9 +79,13 @@ private
(Switch_Chars : String;
Max : Integer;
Ptr : in out Integer;
- Result : out Pos);
+ Result : out Pos;
+ Switch : Character);
-- Scan positive integer parameter for switch. On entry, Ptr points
-- just past the switch character, on exit it points past the last
-- digit of the integer value.
+ procedure Bad_Switch (Switch : Character);
+ -- Fail with an appropriate message when a switch is not recognized
+
end Switch;