From 0e47ff5cdde89f3e89610ace38659e0a8fc37ad1 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Mon, 27 Jul 2009 15:39:44 +0200 Subject: [PATCH] [multiple changes] 2009-07-27 Robert Dewar * g-sse.ads: Minor reformatting 2009-07-27 Arnaud Charlet * xref_lib.adb (Add_Xref_File_Internal, Find_ALI_Files): Add support for alternate ali extension. * xr_tabls.adb (ALI_File_Name, Get_File, Set_Unvisited): Take into account Osint.ALI_Suffix. * osint.ads (ALI_Suffix): Make visible. * gnatfind.adb (Gnatfind): Add support for --ext= switch. * gnat_ugn.texi: Document new gnatfind --ext= switch. 2009-07-27 Ed Schonberg * sem.adb (Walk_Library_Items): If main unit is an instance body, do its spec first. 2009-07-27 Javier Miranda * exp_disp.adb (Expand_Dispatching_Call): Generate the SCIL node after the dispatching call has is expanded. From-SVN: r150115 --- gcc/ada/ChangeLog | 24 ++++++++++ gcc/ada/exp_disp.adb | 22 ++++----- gcc/ada/g-sse.ads | 4 +- gcc/ada/gnat_ugn.texi | 7 +++ gcc/ada/gnatfind.adb | 103 +++++++++++++++++++++++++++--------------- gcc/ada/osint.ads | 7 +-- gcc/ada/sem.adb | 23 +++++++++- gcc/ada/xr_tabls.adb | 13 ++++-- gcc/ada/xref_lib.adb | 6 ++- 9 files changed, 148 insertions(+), 61 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 45ce028e78c..ca9285d0330 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,27 @@ +2009-07-27 Robert Dewar + + * g-sse.ads: Minor reformatting + +2009-07-27 Arnaud Charlet + + * xref_lib.adb (Add_Xref_File_Internal, Find_ALI_Files): Add support for + alternate ali extension. + * xr_tabls.adb (ALI_File_Name, Get_File, Set_Unvisited): Take into + account Osint.ALI_Suffix. + * osint.ads (ALI_Suffix): Make visible. + * gnatfind.adb (Gnatfind): Add support for --ext= switch. + * gnat_ugn.texi: Document new gnatfind --ext= switch. + +2009-07-27 Ed Schonberg + + * sem.adb (Walk_Library_Items): If main unit is an instance body, do + its spec first. + +2009-07-27 Javier Miranda + + * exp_disp.adb (Expand_Dispatching_Call): Generate the SCIL node after + the dispatching call has is expanded. + 2009-07-27 Ed Schonberg * exp_attr.adb (Expand_Attribute_Reference, case 'Valid): Reset the diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb index df23c891f27..010e6bf9e10 100644 --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -643,17 +643,6 @@ package body Exp_Disp is Typ := Non_Limited_View (Typ); end if; - -- Generate the SCIL node for this dispatching call - - if Generate_SCIL then - Insert_Action (Call_Node, - New_SCIL_Node - (SN_Kind => Dispatching_Call, - Related_Node => Call_Node, - Entity => Typ, - Target_Prim => Subp)); - end if; - if not Is_Limited_Type (Typ) then Eq_Prim_Op := Find_Prim_Op (Typ, Name_Op_Eq); end if; @@ -877,6 +866,17 @@ package body Exp_Disp is -- to avoid the generation of spurious warnings under ZFP run-time. Analyze_And_Resolve (Call_Node, Call_Typ, Suppress => All_Checks); + + -- Generate the SCIL node for this dispatching call + + if Generate_SCIL then + Insert_Action (Call_Node, + New_SCIL_Node + (SN_Kind => Dispatching_Call, + Related_Node => Call_Node, + Entity => Typ, + Target_Prim => Subp)); + end if; end Expand_Dispatching_Call; --------------------------------- diff --git a/gcc/ada/g-sse.ads b/gcc/ada/g-sse.ads index 8ce2b5d902d..04eb6d5a914 100644 --- a/gcc/ada/g-sse.ads +++ b/gcc/ada/g-sse.ads @@ -30,8 +30,8 @@ ------------------------------------------------------------------------------ -- This package is the root of a set aimed at offering Ada bindings to a --- subset of the Intel(r) Streaming SIMD Extensions with GNAT. The purpose is --- to allow access from Ada to the SSE facilities defined in the Intel(r) +-- subset of the Intel(r) Streaming SIMD Extensions with GNAT. The purpose +-- is to allow access from Ada to the SSE facilities defined in the Intel(r) -- compiler manuals, in particular in the Intrinsics Reference of the C++ -- Compiler User's Guide, available from http://www.intel.com. diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index a1bb7bf306c..e18a16cccb2 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -15590,6 +15590,13 @@ Do not look for sources in the system default directory. @cindex @option{-nostdlib} (@command{gnatfind}) Do not look for library files in the system default directory. +@item --ext=@var{extension} +@cindex @option{--ext} (@command{gnatfind}) +Specify an alternate ali file extension. The default is @code{ali} and other +extensions (e.g. @code{sli} for SPARK library files) may be specified via this +switch. Note that if this switch overrides the default, which means that only +the new extension will be considered. + @item --RTS=@var{rts-path} @cindex @option{--RTS} (@command{gnatfind}) Specifies the default location of the runtime library. Same meaning as the diff --git a/gcc/ada/gnatfind.adb b/gcc/ada/gnatfind.adb index 69415ef963e..45bc5ee2005 100644 --- a/gcc/ada/gnatfind.adb +++ b/gcc/ada/gnatfind.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1998-2008, Free Software Foundation, Inc. -- +-- Copyright (C) 1998-2009, 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- -- @@ -64,6 +64,9 @@ procedure Gnatfind is RTS_Specified : String_Access := null; -- Used to detect multiple use of --RTS= switch + EXT_Specified : String_Access := null; + -- Used to detect multiple use of --ext= switch + procedure Parse_Cmd_Line; -- Parse every switch on the command line @@ -95,7 +98,7 @@ procedure Gnatfind is loop case GNAT.Command_Line.Getopt - ("a aI: aO: d e f g h I: nostdinc nostdlib p: r s t -RTS=") + ("a aI: aO: d e f g h I: nostdinc nostdlib p: r s t -RTS= -ext=") is when ASCII.NUL => exit; @@ -155,44 +158,71 @@ procedure Gnatfind is -- Only switch starting with -- recognized is --RTS when '-' => - -- Check that it is the first time we see this switch - if RTS_Specified = null then - RTS_Specified := new String'(GNAT.Command_Line.Parameter); + if GNAT.Command_Line.Full_Switch = "-RTS" then + -- Check that it is the first time we see this switch - elsif RTS_Specified.all /= GNAT.Command_Line.Parameter then - Osint.Fail ("--RTS cannot be specified multiple times"); - end if; + if RTS_Specified = null then + RTS_Specified := new String'(GNAT.Command_Line.Parameter); - Opt.No_Stdinc := True; - Opt.RTS_Switch := True; - - declare - Src_Path_Name : constant String_Ptr := - Get_RTS_Search_Dir - (GNAT.Command_Line.Parameter, Include); - Lib_Path_Name : constant String_Ptr := - Get_RTS_Search_Dir - (GNAT.Command_Line.Parameter, Objects); - - begin - if Src_Path_Name /= null and then Lib_Path_Name /= null then - Add_Search_Dirs (Src_Path_Name, Include); - Add_Search_Dirs (Lib_Path_Name, Objects); - - elsif Src_Path_Name = null and then Lib_Path_Name = null then - Osint.Fail ("RTS path not valid: missing " & - "adainclude and adalib directories"); - - elsif Src_Path_Name = null then - Osint.Fail ("RTS path not valid: missing " & - "adainclude directory"); - - elsif Lib_Path_Name = null then - Osint.Fail ("RTS path not valid: missing " & - "adalib directory"); + elsif RTS_Specified.all /= GNAT.Command_Line.Parameter then + Osint.Fail ("--RTS cannot be specified multiple times"); end if; - end; + + Opt.No_Stdinc := True; + Opt.RTS_Switch := True; + + declare + Src_Path_Name : constant String_Ptr := + Get_RTS_Search_Dir + (GNAT.Command_Line.Parameter, + Include); + Lib_Path_Name : constant String_Ptr := + Get_RTS_Search_Dir + (GNAT.Command_Line.Parameter, + Objects); + + begin + if Src_Path_Name /= null + and then Lib_Path_Name /= null + then + Add_Search_Dirs (Src_Path_Name, Include); + Add_Search_Dirs (Lib_Path_Name, Objects); + + elsif Src_Path_Name = null + and then Lib_Path_Name = null + then + Osint.Fail ("RTS path not valid: missing " & + "adainclude and adalib directories"); + + elsif Src_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adainclude directory"); + + elsif Lib_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adalib directory"); + end if; + end; + elsif GNAT.Command_Line.Full_Switch = "-ext" then + -- Check that it is the first time we see this switch + + if EXT_Specified = null then + EXT_Specified := new String'(GNAT.Command_Line.Parameter); + + elsif EXT_Specified.all /= GNAT.Command_Line.Parameter then + Osint.Fail ("--ext cannot be specified multiple times"); + end if; + + if EXT_Specified'Length + = Osint.ALI_Default_Suffix'Length + then + Osint.ALI_Suffix := EXT_Specified.all'Access; + else + Osint.Fail ("--ext argument must have 3 characters"); + end if; + + end if; when others => Write_Usage; @@ -281,6 +311,7 @@ procedure Gnatfind is & " directory"); Put_Line (" -nostdlib Don't look for library files in the system" & " default directory"); + Put_Line (" --ext=xxx Specify alternate ali file extension"); Put_Line (" --RTS=dir specify the default source and object search" & " path"); Put_Line (" -p file Use file as the default project file"); diff --git a/gcc/ada/osint.ads b/gcc/ada/osint.ads index 5de8eced2ac..5ddda479efb 100644 --- a/gcc/ada/osint.ads +++ b/gcc/ada/osint.ads @@ -571,11 +571,12 @@ package Osint is pragma Import (C, Len_Arg, "__gnat_len_arg"); -- Get length of argument -private - - ALI_Suffix : constant String_Ptr := new String'("ali"); + ALI_Default_Suffix : constant String_Ptr := new String'("ali"); + ALI_Suffix : String_Ptr := ALI_Default_Suffix; -- The suffix used for the library files (also known as ALI files) +private + Current_Main : File_Name_Type := No_File; -- Used to save a simple file name between calls to Next_Main_Source and -- Read_Source_File. If the file name argument to Read_Source_File is diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb index 69c4497f135..6f68bdd81ce 100644 --- a/gcc/ada/sem.adb +++ b/gcc/ada/sem.adb @@ -1762,7 +1762,7 @@ package body Sem is if Nkind (Item) = N_Package_Declaration then Body_Unit := Library_Unit (CU); - elsif Nkind (Item) = N_Package_Body then + elsif Nkind_In (Item, N_Package_Body, N_Subprogram_Body) then Body_Unit := CU; end if; @@ -1860,7 +1860,26 @@ package body Sem is if not Done (Main_Unit) then Do_Main := True; - Do_Unit_And_Dependents (Cunit (Main_Unit), Unit (Cunit (Main_Unit))); + + declare + Main_CU : constant Node_Id := Cunit (Main_Unit); + + begin + + -- If the main unit is an instantiation, the body appears + -- before the instance spec, which is added later to the + -- unit list. Do the spec if present, body will follow. + + if Nkind (Original_Node (Unit (Main_CU))) + in N_Generic_Instantiation + and then Present (Library_Unit (Main_CU)) + then + Do_Unit_And_Dependents + (Library_Unit (Main_CU), Unit (Library_Unit (Main_CU))); + else + Do_Unit_And_Dependents (Main_CU, Unit (Main_CU)); + end if; + end; end if; if Debug_Unit_Walk then diff --git a/gcc/ada/xr_tabls.adb b/gcc/ada/xr_tabls.adb index 82b2e7d0382..30a4ecc55a4 100644 --- a/gcc/ada/xr_tabls.adb +++ b/gcc/ada/xr_tabls.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1998-2008, Free Software Foundation, Inc. -- +-- Copyright (C) 1998-2009, 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- -- @@ -495,9 +495,10 @@ package body Xr_Tabls is begin if Index /= 0 then - return Ada_File_Name (Ada_File_Name'First .. Index) & "ali"; + return Ada_File_Name (Ada_File_Name'First .. Index) + & Osint.ALI_Suffix.all; else - return Ada_File_Name & ".ali"; + return Ada_File_Name & "." & Osint.ALI_Suffix.all; end if; end ALI_File_Name; @@ -823,7 +824,9 @@ package body Xr_Tabls is end if; if File.Dir = null then - if Ada.Strings.Fixed.Tail (File.File.all, 3) = "ali" then + if Ada.Strings.Fixed.Tail (File.File.all, 3) + = Osint.ALI_Suffix.all + then Tmp := Locate_Regular_File (Internal_Strip (File.File.all), Directories.Obj_Dir); else @@ -1392,7 +1395,7 @@ package body Xr_Tabls is -- least for gnatxref, and probably for gnatfind as well if F'Length > 4 - and then F (F'Last - 3 .. F'Last) = ".ali" + and then F (F'Last - 3 .. F'Last) = "." & Osint.ALI_Suffix.all then Unvisited_Files := new Unvisited_Files_Record' (File => File_Ref, diff --git a/gcc/ada/xref_lib.adb b/gcc/ada/xref_lib.adb index 935291328fe..475f15e3816 100644 --- a/gcc/ada/xref_lib.adb +++ b/gcc/ada/xref_lib.adb @@ -308,7 +308,7 @@ package body Xref_Lib is -- Case where we have an ALI file, accept it even though this is -- not official usage, since the intention is obvious - if Tail (File, 4) = ".ali" then + if Tail (File, 4) = "." & Osint.ALI_Suffix.all then File_Ref := Add_To_Xref_File (File, Visited => False, Emit_Warning => True); @@ -466,7 +466,9 @@ package body Xref_Lib is return; end if; - elsif Last > 4 and then Dir_Ent (Last - 3 .. Last) = ".ali" then + elsif Last > 4 + and then Dir_Ent (Last - 3 .. Last) = "." & Osint.ALI_Suffix.all + then File_Ref := Add_To_Xref_File (Dir_Ent (1 .. Last), Visited => False); end if;