Patchwork [Ada] PR ada/44633

login
register
mail settings
Submitter Arnaud Charlet
Date June 23, 2010, 9:15 a.m.
Message ID <20100623091512.GA8211@adacore.com>
Download mbox | patch
Permalink /patch/56618/
State New
Headers show

Comments

Arnaud Charlet - June 23, 2010, 9:15 a.m.
This is a follow up from the previous change, to take into account properly
all compiler switches in gnatmake -s switch, and fixes PR ada/44633 along the
way.

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

2010-06-23  Vincent Celier  <celier@adacore.com>

	PR ada/44633
	* switch-m.adb (Normalize_Compiler_Switches): Take into account
	switches -gnatB, -gnatD=nn, -gnatG (incuding -gnatG=nn), -gnatI,
	-gnatl=file, -gnatS, -gnatjnn, -gnateI=nn and -gnatWx.

Patch

Index: switch-m.adb
===================================================================
--- switch-m.adb	(revision 161263)
+++ switch-m.adb	(working copy)
@@ -215,9 +215,9 @@  package body Switch.M is
 
                   --  One-letter switches
 
-                  when 'a' | 'A' | 'b' | 'c' | 'C' | 'D' | 'E' | 'f' |
-                       'F' | 'g' | 'h' | 'H' | 'l' | 'L' | 'n' | 'N' |
-                       'o' | 'O' | 'p' | 'P' | 'q' | 'Q' | 'r' | 's' |
+                  when 'a' | 'A' | 'b' | 'B' | 'c' | 'C' | 'E' | 'f' |
+                       'F' | 'g' | 'h' | 'H' | 'I' | 'L' | 'n' | 'N' |
+                       'o' | 'p' | 'P' | 'q' | 'Q' | 'r' | 's' | 'S' |
                        't' | 'u' | 'U' | 'v' | 'x' | 'X' | 'Z' =>
                      Storing (First_Stored) := C;
                      Add_Switch_Component
@@ -226,10 +226,14 @@  package body Switch.M is
 
                   --  One-letter switches followed by a positive number
 
-                  when 'k' | 'm' | 'T' =>
+                  when 'D' | 'G' | 'j' | 'k' | 'm' | 'T' =>
                      Storing (First_Stored) := C;
                      Last_Stored := First_Stored;
 
+                     if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
+                        Ptr := Ptr + 1;
+                     end if;
+
                      loop
                         Ptr := Ptr + 1;
                         exit when Ptr > Max
@@ -268,68 +272,93 @@  package body Switch.M is
 
                   when 'e' =>
 
-                     --  Store -gnateD, -gnatep=, -gnateG and -gnateS in the
-                     --  ALI file. The other -gnate switches do not need to be
-                     --  stored.
+                     --  Some of the gnate... switches are not stored
 
                      Storing (First_Stored) := 'e';
                      Ptr := Ptr + 1;
 
-                     if Ptr > Max
-                       or else (Switch_Chars (Ptr) /= 'D'
-                                 and then Switch_Chars (Ptr) /= 'G'
-                                 and then Switch_Chars (Ptr) /= 'p'
-                                 and then Switch_Chars (Ptr) /= 'S')
-                     then
+                     if Ptr > Max then
                         Last := 0;
                         return;
-                     end if;
 
-                     --  Processing for -gnateD
+                     else
+                        case Switch_Chars (Ptr) is
 
-                     if Switch_Chars (Ptr) = 'D' then
-                        Storing (First_Stored + 1 ..
-                                 First_Stored + Max - Ptr + 1) :=
-                          Switch_Chars (Ptr .. Max);
-                        Add_Switch_Component
-                          (Storing (Storing'First ..
-                                      First_Stored + Max - Ptr + 1));
+                           when 'D' =>
+                              Storing (First_Stored + 1 ..
+                                         First_Stored + Max - Ptr + 1) :=
+                                  Switch_Chars (Ptr .. Max);
+                              Add_Switch_Component
+                                (Storing (Storing'First ..
+                                   First_Stored + Max - Ptr + 1));
+                              Ptr := Max + 1;
 
-                     --  Processing for -gnatep=
+                           when 'G' =>
+                              Ptr := Ptr + 1;
+                              Add_Switch_Component ("-gnateG");
 
-                     elsif Switch_Chars (Ptr) = 'p' then
-                        Ptr := Ptr + 1;
+                           when 'I' =>
+                              Ptr := Ptr + 1;
 
-                        if Ptr = Max then
-                           Last := 0;
-                           return;
-                        end if;
+                              declare
+                                 First : constant Positive := Ptr - 1;
+                              begin
+                                 if Ptr <= Max and then
+                                   Switch_Chars (Ptr) = '='
+                                 then
+                                    Ptr := Ptr + 1;
+                                 end if;
+
+                                 while Ptr <= Max and then
+                                       Switch_Chars (Ptr) in '0' .. '9'
+                                 loop
+                                    Ptr := Ptr + 1;
+                                 end loop;
+
+                                 Storing (First_Stored + 1 ..
+                                            First_Stored + Ptr - First) :=
+                                     Switch_Chars (First .. Ptr - 1);
+                                 Add_Switch_Component
+                                   (Storing (Storing'First ..
+                                      First_Stored + Ptr - First));
+                              end;
 
-                        if Switch_Chars (Ptr) = '=' then
-                           Ptr := Ptr + 1;
-                        end if;
+                           when 'p' =>
+                              Ptr := Ptr + 1;
 
-                        --  To normalize, always put a '=' after -gnatep.
-                        --  Because that could lengthen the switch string,
-                        --  declare a local variable.
-
-                        declare
-                           To_Store : String (1 .. Max - Ptr + 9);
-                        begin
-                           To_Store (1 .. 8) := "-gnatep=";
-                           To_Store (9 .. Max - Ptr + 9) :=
-                             Switch_Chars (Ptr .. Max);
-                           Add_Switch_Component (To_Store);
-                        end;
+                              if Ptr = Max then
+                                 Last := 0;
+                                 return;
+                              end if;
+
+                              if Switch_Chars (Ptr) = '=' then
+                                 Ptr := Ptr + 1;
+                              end if;
+
+                                 --  To normalize, always put a '=' after
+                                 --  -gnatep. Because that could lengthen the
+                                 --  switch string, declare a local variable.
+
+                              declare
+                                 To_Store : String (1 .. Max - Ptr + 9);
+                              begin
+                                 To_Store (1 .. 8) := "-gnatep=";
+                                 To_Store (9 .. Max - Ptr + 9) :=
+                                   Switch_Chars (Ptr .. Max);
+                                 Add_Switch_Component (To_Store);
+                              end;
 
-                     elsif Switch_Chars (Ptr) = 'G' then
-                        Add_Switch_Component ("-gnateG");
+                              return;
 
-                     elsif Switch_Chars (Ptr) = 'S' then
-                        Add_Switch_Component ("-gnateS");
-                     end if;
+                           when 'S' =>
+                              Ptr := Ptr + 1;
+                              Add_Switch_Component ("-gnateS");
 
-                     return;
+                           when others =>
+                              Last := 0;
+                              return;
+                        end case;
+                     end if;
 
                   when 'i' =>
                      Storing (First_Stored) := 'i';
@@ -360,6 +389,20 @@  package body Switch.M is
                         return;
                      end if;
 
+                  --  -gnatl may be -gnatl=<file name>
+
+                  when 'l' =>
+                     Ptr := Ptr + 1;
+
+                     if Ptr > Max or else Switch_Chars (Ptr) /= '=' then
+                        Add_Switch_Component ("-gnatl");
+
+                     else
+                        Add_Switch_Component
+                          ("-gnatl" & Switch_Chars (Ptr .. Max));
+                        return;
+                     end if;
+
                   --  -gnatR may be followed by '0', '1', '2' or '3',
                   --  then by 's'
 
@@ -395,6 +438,26 @@  package body Switch.M is
                      Add_Switch_Component
                        (Storing (Storing'First .. Last_Stored));
 
+                  --  -gnatWx, x = 'h'. 'u', 's', 'e', '8' or 'b'
+
+                  when 'W' =>
+                     Storing (First_Stored) := 'W';
+                     Ptr := Ptr + 1;
+
+                     if Ptr <= Max then
+                        case Switch_Chars (Ptr) is
+                           when 'h' | 'u' | 's' | 'e' | '8' | 'b' =>
+                              Storing (First_Stored + 1) := Switch_Chars (Ptr);
+                              Add_Switch_Component
+                                (Storing (Storing'First .. First_Stored + 1));
+                              Ptr := Ptr + 1;
+
+                           when others =>
+                              Last := 0;
+                              return;
+                        end case;
+                     end if;
+
                   --  Multiple switches
 
                   when 'V' | 'w' | 'y' =>