]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* gnat.dg/loop_optimization9.ad[sb]: New test.
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 10 Nov 2011 10:48:11 +0000 (10:48 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 10 Nov 2011 10:48:11 +0000 (10:48 +0000)
From-SVN: r181252

gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/loop_optimization9.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/loop_optimization9.ads [new file with mode: 0644]

index 2d7d99b431f80bd02b4f9117eef384bdb19b318b..833db9b117ac30156e508df8d93e79fdb453b57b 100644 (file)
@@ -1,3 +1,7 @@
+2011-11-10  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/loop_optimization9.ad[sb]: New test.
+
 2011-11-10  Ira Rosen  <ira.rosen@linaro.org>
 
        PR tree-optimization/51058
diff --git a/gcc/testsuite/gnat.dg/loop_optimization9.adb b/gcc/testsuite/gnat.dg/loop_optimization9.adb
new file mode 100644 (file)
index 0000000..56d85e2
--- /dev/null
@@ -0,0 +1,124 @@
+-- { dg-do compile }
+-- { dg-options "-gnatws -O3" }
+-- { dg-options "-gnatws -O3 -msse" { target i?86-*-* x86_64-*-* } }
+
+with System.Soft_Links;
+
+package body Loop_Optimization9 is
+
+   package SSL renames System.Soft_Links;
+
+   First_Temp_File_Name : constant String := "GNAT-TEMP-000000.TMP";
+
+   Current_Temp_File_Name : String := First_Temp_File_Name;
+
+   Temp_File_Name_Last_Digit : constant Positive :=
+                                 First_Temp_File_Name'Last - 4;
+
+   function Argument_String_To_List
+     (Arg_String : String) return Argument_List_Access
+   is
+      Max_Args : constant Integer := Arg_String'Length;
+      New_Argv : Argument_List (1 .. Max_Args);
+      New_Argc : Natural := 0;
+      Idx      : Integer;
+
+   begin
+      Idx := Arg_String'First;
+
+      loop
+         exit when Idx > Arg_String'Last;
+
+         declare
+            Quoted  : Boolean := False;
+            Backqd  : Boolean := False;
+            Old_Idx : Integer;
+
+         begin
+            Old_Idx := Idx;
+
+            loop
+               --  An unquoted space is the end of an argument
+
+               if not (Backqd or Quoted)
+                 and then Arg_String (Idx) = ' '
+               then
+                  exit;
+
+               --  Start of a quoted string
+
+               elsif not (Backqd or Quoted)
+                 and then Arg_String (Idx) = '"'
+               then
+                  Quoted := True;
+
+               --  End of a quoted string and end of an argument
+
+               elsif (Quoted and not Backqd)
+                 and then Arg_String (Idx) = '"'
+               then
+                  Idx := Idx + 1;
+                  exit;
+
+               --  Following character is backquoted
+
+               elsif Arg_String (Idx) = '\' then
+                  Backqd := True;
+
+               --  Turn off backquoting after advancing one character
+
+               elsif Backqd then
+                  Backqd := False;
+
+               end if;
+
+               Idx := Idx + 1;
+               exit when Idx > Arg_String'Last;
+            end loop;
+
+            --  Found an argument
+
+            New_Argc := New_Argc + 1;
+            New_Argv (New_Argc) :=
+              new String'(Arg_String (Old_Idx .. Idx - 1));
+         end;
+      end loop;
+
+      return new Argument_List'(New_Argv (1 .. New_Argc));
+   end Argument_String_To_List;
+
+   procedure Create_Temp_File_Internal
+     (FD        : out File_Descriptor;
+      Name      : out String_Access)
+   is
+      Pos      : Positive;
+   begin
+      File_Loop : loop
+         Locked : begin
+            Pos := Temp_File_Name_Last_Digit;
+
+            Digit_Loop :
+            loop
+               case Current_Temp_File_Name (Pos) is
+                  when '0' .. '8' =>
+                     Current_Temp_File_Name (Pos) :=
+                       Character'Succ (Current_Temp_File_Name (Pos));
+                     exit Digit_Loop;
+
+                  when '9' =>
+                     Current_Temp_File_Name (Pos) := '0';
+                     Pos := Pos - 1;
+
+                  when others =>
+
+                     SSL.Unlock_Task.all;
+                     FD := 0;
+                     Name := null;
+                     exit File_Loop;
+               end case;
+            end loop Digit_Loop;
+         end Locked;
+      end loop File_Loop;
+   end Create_Temp_File_Internal;
+
+end Loop_Optimization9;
diff --git a/gcc/testsuite/gnat.dg/loop_optimization9.ads b/gcc/testsuite/gnat.dg/loop_optimization9.ads
new file mode 100644 (file)
index 0000000..95f8221
--- /dev/null
@@ -0,0 +1,18 @@
+with GNAT.Strings; use GNAT.Strings;
+
+package Loop_Optimization9 is
+
+   type File_Descriptor is new Integer;
+
+   procedure Create_Temp_File_Internal
+     (FD   : out File_Descriptor;
+      Name : out String_Access);
+
+   subtype Argument_List is String_List;
+
+   subtype Argument_List_Access is String_List_Access;
+
+   function Argument_String_To_List
+     (Arg_String : String) return Argument_List_Access;
+
+end Loop_Optimization9;