From: Arnaud Charlet Date: Tue, 12 Oct 2010 12:37:50 +0000 (+0200) Subject: [multiple changes] X-Git-Tag: upstream/12.2.0~89443 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=38ef8ebee3938a622889f818d417de171cdb8a77;p=platform%2Fupstream%2Fgcc.git [multiple changes] 2010-10-12 Javier Miranda * sem_ch6.adb (New_Overloaded_Entity): Add missing decoration of attribute Overridden_Operation in predefined dispatching primitives. 2010-10-12 Emmanuel Briot * g-comlin.adb, g-comlin.ads (Add_Switch): Raise an exception when a command line configuration exists and we specify an invalid section. From-SVN: r165368 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 7e6bc3a..2863126 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2010-10-12 Javier Miranda + + * sem_ch6.adb (New_Overloaded_Entity): Add missing decoration of + attribute Overridden_Operation in predefined dispatching primitives. + +2010-10-12 Emmanuel Briot + + * g-comlin.adb, g-comlin.ads (Add_Switch): Raise an exception when a + command line configuration exists and we specify an invalid section. + 2010-10-12 Robert Dewar * sem_ch6.adb (Process_PPCs): Fix error in inheriting Pre'Class when no diff --git a/gcc/ada/g-comlin.adb b/gcc/ada/g-comlin.adb index eb98254..1de4417 100644 --- a/gcc/ada/g-comlin.adb +++ b/gcc/ada/g-comlin.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1999-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1999-2010, 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- -- @@ -1755,7 +1755,21 @@ package body GNAT.Command_Line is -- Start of processing for Add_Switch + Section_Valid : Boolean := False; begin + if Section /= "" and then Cmd.Config /= null then + for S in Cmd.Config.Sections'Range loop + if Section = Cmd.Config.Sections (S).all then + Section_Valid := True; + exit; + end if; + end loop; + + if not Section_Valid then + raise Invalid_Section; + end if; + end if; + Success := False; Add_Simple_Switches (Cmd, Switch, Parameter); Free (Cmd.Coalesce); @@ -2252,7 +2266,7 @@ package body GNAT.Command_Line is procedure Start (Cmd : in out Command_Line; Iter : in out Command_Line_Iterator; - Expanded : Boolean) + Expanded : Boolean := False) is begin if Cmd.Expanded = null then diff --git a/gcc/ada/g-comlin.ads b/gcc/ada/g-comlin.ads index cea2e7b..d760a81 100644 --- a/gcc/ada/g-comlin.ads +++ b/gcc/ada/g-comlin.ads @@ -33,8 +33,9 @@ -- High level package for command line parsing and manipulation --- Parsing the command line --- ======================== +-------------------------------------- +-- Simple parsing of the command line +-------------------------------------- -- This package provides an interface for parsing command line arguments, -- when they are either read from Ada.Command_Line or read from a string list. @@ -81,6 +82,10 @@ -- when Invalid_Parameter => Put_Line ("No parameter for " & Full_Switch); -- end; +------------- +-- Sections +------------- + -- A more complicated example would involve the use of sections for the -- switches, as for instance in gnatmake. The same command line is used to -- provide switches for several tools. Each tool recognizes its switches by @@ -106,6 +111,10 @@ -- end loop; -- end; +------------------------------ +-- Parsing a list of strings +------------------------------ + -- The examples above show how to parse the command line when the arguments -- are read directly from Ada.Command_Line. However, these arguments can also -- be read from a list of strings. This can be useful in several contexts, @@ -132,9 +141,10 @@ -- end loop; -- Free (Parser); -- end; --- + +---------------------------------------------- -- Creating and manipulating the command line --- =========================================== +---------------------------------------------- -- This package provides mechanisms to create and modify command lines by -- adding or removing arguments from them. The resulting command line is kept @@ -204,13 +214,14 @@ -- This is done by passing an extra argument to Add_Switch, as in: --- Add_Switch (Cmd, "-foo", "arg1"); +-- Add_Switch (Cmd, "-foo", Parameter => "arg1"); -- This ensures that "arg1" will always be treated as the argument to -foo, -- and will not be grouped with other parts of the command line. +--------------------------------------------------- -- Parsing the command line with grouped arguments --- =============================================== +--------------------------------------------------- -- The command line construction facility can also be used in conjunction with -- Getopt to interpret a command line. For example when implementing the tool @@ -230,8 +241,10 @@ -- Start (Cmd, Iter, Expanded => True); -- while Has_More (Iter) loop --- if Current_Switch (Iter) = "-gnatwu" then .. --- elsif Current_Switch (Iter) = "-gnatwv" then ... +-- if Current_Switch (Iter) = "-gnatwu" then +-- ... +-- elsif Current_Switch (Iter) = "-gnatwv" then +-- ... -- end if; -- Next (Iter); -- end loop; @@ -444,6 +457,24 @@ package GNAT.Command_Line is -- the parameter were concatenated. A space is returned if the switch and -- its argument were in two separate arguments. + Invalid_Section : exception; + -- Raised when an invalid section is selected by Goto_Section + + Invalid_Switch : exception; + -- Raised when an invalid switch is detected in the command line + + Invalid_Parameter : exception; + -- Raised when a parameter is missing, or an attempt is made to obtain a + -- parameter for a switch that does not allow a parameter + + ----------------------------------------- + -- Expansion of command line arguments -- + ----------------------------------------- + -- These subprograms take care of of expanding globbing patterns on the + -- command line. On Unix, such expansion is done by the shell before your + -- application is called. But on Windows you must do this expansion + -- yourself. + type Expansion_Iterator is limited private; -- Type used during expansion of file names @@ -475,19 +506,16 @@ package GNAT.Command_Line is -- If Expansion is called again after an empty string has been returned, -- then the exception GNAT.Directory_Operations.Directory_Error is raised. - Invalid_Section : exception; - -- Raised when an invalid section is selected by Goto_Section - - Invalid_Switch : exception; - -- Raised when an invalid switch is detected in the command line - - Invalid_Parameter : exception; - -- Raised when a parameter is missing, or an attempt is made to obtain a - -- parameter for a switch that does not allow a parameter - ----------------- -- Configuring -- ----------------- + -- The following subprograms are used to manipulate a command line + -- represented as a string (for instance "-g -O2"), as well as parsing + -- the switches from such a string. They provide high-level configurations + -- to define aliases (a switch is equivalent to one or more other switches) + -- or grouping of switches ("-gnatyac" is equivalent to "-gnatya" and + -- "-gnatyc"). + -- See the top of this file for examples on how to use these subprograms type Command_Line_Configuration is private; @@ -499,9 +527,6 @@ package GNAT.Command_Line is -- be expanded as Expanded. For instance, for the GNAT compiler switches, -- we would define "-gnatwa" as an alias for "-gnatwcfijkmopruvz", ie some -- default warnings to be activated. - -- - -- Likewise, in some context you could define "--verbose" as an alias for - -- ("-v", "--full"), ie two switches. procedure Define_Prefix (Config : in out Command_Line_Configuration; @@ -537,20 +562,25 @@ package GNAT.Command_Line is procedure Free (Config : in out Command_Line_Configuration); -- Free the memory used by Config - ------------- - -- Editing -- - ------------- + ------------------------------ + -- Generating command lines -- + ------------------------------ + -- Once the command line configuration has been created, you can build your + -- own command line. This will be done in general because you need to spawn + -- external tools from your application. + -- Although it could be done by concatenating strings, the following + -- subprograms will properly take care of grouping switches when possible, + -- so as to keep the command line as short as possible. They also provide a + -- way to remove a switch from an existing command line. type Command_Line is private; procedure Set_Configuration (Cmd : in out Command_Line; Config : Command_Line_Configuration); - -- Set the configuration for this command line - function Get_Configuration (Cmd : Command_Line) return Command_Line_Configuration; - -- Return the configuration used for that command line + -- Set or retrieve the configuration used for that command line procedure Set_Command_Line (Cmd : in out Command_Line; @@ -608,7 +638,10 @@ package GNAT.Command_Line is -- If the switch is part of a section, then it should be specified so that -- the switch is correctly placed in the command line, and the section -- added if not already present. For example, to add the -g switch into the - -- -cargs section, you need to pass (Cmd, "-g", Section => "-cargs"). + -- -cargs section, you need to call (Cmd, "-g", Section => "-cargs"). + -- + -- Invalid_Section is raised if Section was not defined in the + -- configuration of the command line. -- -- Add_Before allows insertion of the switch at the beginning of the -- command line. @@ -672,13 +705,15 @@ package GNAT.Command_Line is --------------- -- Iteration -- --------------- + -- When a command line was created with the above, you can then iterate + -- over its contents using the following iterator. type Command_Line_Iterator is private; procedure Start (Cmd : in out Command_Line; Iter : in out Command_Line_Iterator; - Expanded : Boolean); + Expanded : Boolean := False); -- Start iterating over the command line arguments. If Expanded is true, -- then the arguments are not grouped and no alias is used. For instance, -- "-gnatwv" and "-gnatwu" would be returned instead of "-gnatwuv". diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index b3a906e..d3e5e56 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -8103,12 +8103,13 @@ package body Sem_Ch6 is Check_Overriding_Indicator (S, E, Is_Primitive => True); -- If S is a user-defined subprogram or a null procedure - -- expanded to override an inherited null procedure, then - -- indicate that E overrides the operation from which S - -- is inherited. It seems odd that Overridden_Operation - -- isn't set in all cases where Is_Overriding_Operation - -- is true, but doing so causes infinite loops in the - -- compiler for implicit overriding subprograms. ??? + -- expanded to override an inherited null procedure, or a + -- predefined dispatching primitive then indicate that E + -- overrides the operation from which S is inherited. It + -- seems odd that Overridden_Operation isn't set in all + -- cases where Is_Overriding_Operation is true, but doing + -- so causes infinite loops in the compiler for implicit + -- overriding subprograms. ??? if Comes_From_Source (S) or else @@ -8117,6 +8118,10 @@ package body Sem_Ch6 is Nkind (Parent (S)) = N_Procedure_Specification and then Null_Present (Parent (S))) + or else + (Present (Alias (E)) + and then + Is_Predefined_Dispatching_Operation (Alias (E))) then if Present (Alias (E)) then Set_Overridden_Operation (S, Alias (E));