Commit 9caf55e3 by Bob Duff Committed by Arnaud Charlet

frontend.adb (Frontend): Skip -gnatec=gnat.adc switch, because we've already…

frontend.adb (Frontend): Skip -gnatec=gnat.adc switch, because we've already read gnat.adc by default.

2017-09-06  Bob Duff  <duff@adacore.com>

	* frontend.adb (Frontend): Skip -gnatec=gnat.adc
	switch, because we've already read gnat.adc by default.

2017-09-06  Bob Duff  <duff@adacore.com>

	* exp_ch5.adb (Get_Default_Iterator): Replace
	"Assert(False)" with "return Iter", because if an iterable
	type is derived from a noniterable one, then we won't find an
	overriding or inherited default iterator.

From-SVN: r251774
parent 6877306f
2017-09-06 Bob Duff <duff@adacore.com>
* frontend.adb (Frontend): Skip -gnatec=gnat.adc
switch, because we've already read gnat.adc by default.
2017-09-06 Bob Duff <duff@adacore.com>
* exp_ch5.adb (Get_Default_Iterator): Replace
"Assert(False)" with "return Iter", because if an iterable
type is derived from a noniterable one, then we won't find an
overriding or inherited default iterator.
2017-09-06 Yannick Moy <moy@adacore.com> 2017-09-06 Yannick Moy <moy@adacore.com>
* sem_warn.adb (Warn_On_Suspicious_Index): Improve warning when the * sem_warn.adb (Warn_On_Suspicious_Index): Improve warning when the
......
...@@ -3934,9 +3934,9 @@ package body Exp_Ch5 is ...@@ -3934,9 +3934,9 @@ package body Exp_Ch5 is
function Get_Default_Iterator function Get_Default_Iterator
(T : Entity_Id) return Entity_Id; (T : Entity_Id) return Entity_Id;
-- If the container is a derived type, the aspect holds the parent -- Return the default iterator for a specific type. If the type is
-- operation. The required one is a primitive of the derived type -- derived, we return the inherited or overridden one if
-- and is either inherited or overridden. Also sets Container_Arg. -- appropriate.
-------------------------- --------------------------
-- Get_Default_Iterator -- -- Get_Default_Iterator --
...@@ -3953,11 +3953,11 @@ package body Exp_Ch5 is ...@@ -3953,11 +3953,11 @@ package body Exp_Ch5 is
begin begin
Container_Arg := New_Copy_Tree (Container); Container_Arg := New_Copy_Tree (Container);
-- A previous version of GNAT allowed indexing aspects to -- A previous version of GNAT allowed indexing aspects to be
-- be redefined on derived container types, while the -- redefined on derived container types, while the default
-- default iterator was inherited from the parent type. -- iterator was inherited from the parent type. This
-- This non-standard extension is preserved temporarily for -- nonstandard extension is preserved for use by the
-- use by the modelling project under debug flag d.X. -- modelling project under debug flag -gnatd.X.
if Debug_Flag_Dot_XX then if Debug_Flag_Dot_XX then
if Base_Type (Etype (Container)) /= if Base_Type (Etype (Container)) /=
...@@ -3995,9 +3995,11 @@ package body Exp_Ch5 is ...@@ -3995,9 +3995,11 @@ package body Exp_Ch5 is
Next_Elmt (Prim); Next_Elmt (Prim);
end loop; end loop;
-- Default iterator must exist -- If we didn't find it, then our parent type is not
-- iterable, so we return the Default_Iterator aspect of
-- this type.
pragma Assert (False); return Iter;
-- Otherwise not a derived type -- Otherwise not a derived type
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2016, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2017, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -68,9 +68,6 @@ with Tbuild; use Tbuild; ...@@ -68,9 +68,6 @@ with Tbuild; use Tbuild;
with Types; use Types; with Types; use Types;
procedure Frontend is procedure Frontend is
Config_Pragmas : List_Id;
-- Gather configuration pragmas
begin begin
-- Carry out package initializations. These are initializations which might -- Carry out package initializations. These are initializations which might
-- logically be performed at elaboration time, were it not for the fact -- logically be performed at elaboration time, were it not for the fact
...@@ -136,6 +133,12 @@ begin ...@@ -136,6 +133,12 @@ begin
-- Read and process configuration pragma files if present -- Read and process configuration pragma files if present
declare declare
Config_Pragmas : List_Id := Empty_List;
-- Gather configuration pragmas
Gnat_Adc : constant File_Name_Type := Name_Find ("gnat.adc");
Dot_Gnat_Adc : constant File_Name_Type := Name_Find ("./gnat.adc");
Save_Style_Check : constant Boolean := Opt.Style_Check; Save_Style_Check : constant Boolean := Opt.Style_Check;
-- Save style check mode so it can be restored later -- Save style check mode so it can be restored later
...@@ -144,8 +147,6 @@ begin ...@@ -144,8 +147,6 @@ begin
Prag : Node_Id; Prag : Node_Id;
Temp_File : Boolean;
begin begin
-- We always analyze config files with style checks off, since we -- We always analyze config files with style checks off, since we
-- don't want a miscellaneous gnat.adc that is around to discombobulate -- don't want a miscellaneous gnat.adc that is around to discombobulate
...@@ -162,9 +163,7 @@ begin ...@@ -162,9 +163,7 @@ begin
-- First deal with gnat.adc file -- First deal with gnat.adc file
if Opt.Config_File then if Opt.Config_File then
Name_Buffer (1 .. 8) := "gnat.adc"; Source_gnat_adc := Load_Config_File (Gnat_Adc);
Name_Len := 8;
Source_gnat_adc := Load_Config_File (Name_Enter);
-- Case of gnat.adc file present -- Case of gnat.adc file present
...@@ -175,20 +174,11 @@ begin ...@@ -175,20 +174,11 @@ begin
Initialize_Scanner (No_Unit, Source_gnat_adc); Initialize_Scanner (No_Unit, Source_gnat_adc);
Config_Pragmas := Par (Configuration_Pragmas => True); Config_Pragmas := Par (Configuration_Pragmas => True);
-- We unconditionally add a compilation dependency for gnat.adc -- We add a compilation dependency for gnat.adc so that if it
-- so that if it changes, we force a recompilation. This is a -- changes, we force a recompilation.
-- fairly recent (2014-03-28) change.
Prepcomp.Add_Dependency (Source_gnat_adc); Prepcomp.Add_Dependency (Source_gnat_adc);
-- Case of no gnat.adc file present
else
Config_Pragmas := Empty_List;
end if; end if;
else
Config_Pragmas := Empty_List;
end if; end if;
-- Now deal with specified config pragmas files if there are any -- Now deal with specified config pragmas files if there are any
...@@ -198,32 +188,38 @@ begin ...@@ -198,32 +188,38 @@ begin
-- Loop through config pragmas files -- Loop through config pragmas files
for Index in Opt.Config_File_Names'Range loop for Index in Opt.Config_File_Names'Range loop
declare
-- See if extension is .TMP/.tmp indicating a temporary config Len : constant Natural := Config_File_Names (Index)'Length;
-- file (which we ignore from the dependency point of view). Str : constant String (1 .. Len) :=
Config_File_Names (Index).all;
Name_Len := Config_File_Names (Index)'Length; Config_Name : constant File_Name_Type := Name_Find (Str);
Name_Buffer (1 .. Name_Len) := Config_File_Names (Index).all; Temp_File : constant Boolean := Len > 4
Temp_File :=
Name_Len > 4
and then and then
(Name_Buffer (Name_Len - 3 .. Name_Len) = ".TMP" (Str (Len - 3 .. Len) = ".TMP"
or else or else
Name_Buffer (Name_Len - 3 .. Name_Len) = ".tmp"); Str (Len - 3 .. Len) = ".tmp");
-- Extension indicating a temporary config file?
begin
-- Skip it if it's the default name, already loaded above.
-- Otherwise, we get confusing warning messages about
-- seeing the same thing twice.
if Config_Name /= Gnat_Adc
and then Config_Name /= Dot_Gnat_Adc
then
-- Load the file, error if we did not find it -- Load the file, error if we did not find it
Source_Config_File := Load_Config_File (Name_Enter); Source_Config_File := Load_Config_File (Config_Name);
if Source_Config_File = No_Source_File then if Source_Config_File = No_Source_File then
Osint.Fail Osint.Fail
("cannot find configuration pragmas file " ("cannot find configuration pragmas file "
& Config_File_Names (Index).all); & Config_File_Names (Index).all);
-- If we did find the file, and it is not a temporary file, then -- If we did find the file, and it is not a temporary file,
-- we unconditionally add a compilation dependency for it so -- then we add a compilation dependency for it so that if it
-- that if it changes, we force a recompilation. This is a -- changes, we force a recompilation.
-- fairly recent (2014-03-28) change.
elsif not Temp_File then elsif not Temp_File then
Prepcomp.Add_Dependency (Source_Config_File); Prepcomp.Add_Dependency (Source_Config_File);
...@@ -234,6 +230,8 @@ begin ...@@ -234,6 +230,8 @@ begin
Initialize_Scanner (No_Unit, Source_Config_File); Initialize_Scanner (No_Unit, Source_Config_File);
Append_List_To Append_List_To
(Config_Pragmas, Par (Configuration_Pragmas => True)); (Config_Pragmas, Par (Configuration_Pragmas => True));
end if;
end;
end loop; end loop;
end if; end if;
...@@ -260,10 +258,9 @@ begin ...@@ -260,10 +258,9 @@ begin
-- Capture any modifications to suppress options from config pragmas -- Capture any modifications to suppress options from config pragmas
Opt.Suppress_Options := Scope_Suppress; Opt.Suppress_Options := Scope_Suppress;
end;
-- If a target dependency info file has been read through switch -gnateT=, -- If a target dependency info file has been read through switch
-- add it to the dependencies. -- -gnateT=, add it to the dependencies.
if Target_Dependent_Info_Read_Name /= null then if Target_Dependent_Info_Read_Name /= null then
declare declare
...@@ -276,14 +273,15 @@ begin ...@@ -276,14 +273,15 @@ begin
end; end;
end if; end if;
-- This is where we can capture the value of the compilation unit specific -- This is where we can capture the value of the compilation unit
-- restrictions that have been set by the config pragma files (or from -- specific restrictions that have been set by the config pragma
-- Targparm), for later restoration when processing e.g. subunits. -- files (or from Targparm), for later restoration when processing
-- e.g. subunits.
Save_Config_Cunit_Boolean_Restrictions; Save_Config_Cunit_Boolean_Restrictions;
-- If there was a -gnatem switch, initialize the mappings of unit names to -- If there was a -gnatem switch, initialize the mappings of unit names
-- file names and of file names to path names from the mapping file. -- to file names and of file names to path names from the mapping file.
if Mapping_File_Name /= null then if Mapping_File_Name /= null then
Fmap.Initialize (Mapping_File_Name.all); Fmap.Initialize (Mapping_File_Name.all);
...@@ -297,9 +295,10 @@ begin ...@@ -297,9 +295,10 @@ begin
Optimize_Alignment := 'T'; Optimize_Alignment := 'T';
end if; end if;
-- We have now processed the command line switches, and the configuration -- We have now processed the command line switches, and the
-- pragma files, so this is the point at which we want to capture the -- configuration pragma files, so this is the point at which we want to
-- values of the configuration switches (see Opt for further details). -- capture the values of the configuration switches (see Opt for further
-- details).
Opt.Register_Opt_Config_Switches; Opt.Register_Opt_Config_Switches;
...@@ -334,16 +333,16 @@ begin ...@@ -334,16 +333,16 @@ begin
if Config_Pragmas /= Error_List if Config_Pragmas /= Error_List
and then Operating_Mode /= Check_Syntax and then Operating_Mode /= Check_Syntax
-- Do not attempt to process deferred configuration pragmas if the main -- Do not attempt to process deferred configuration pragmas if the
-- unit failed to load, to avoid cascaded inconsistencies that can lead -- main unit failed to load, to avoid cascaded inconsistencies that
-- to a compiler crash. -- can lead to a compiler crash.
and then Fatal_Error (Main_Unit) /= Error_Detected and then Fatal_Error (Main_Unit) /= Error_Detected
then then
-- Pragmas that require some semantic activity, such as Interrupt_State, -- Pragmas that require some semantic activity, such as
-- cannot be processed until the main unit is installed, because they -- Interrupt_State, cannot be processed until the main unit is
-- require a compilation unit on which to attach with_clauses, etc. So -- installed, because they require a compilation unit on which to
-- analyze them now. -- attach with_clauses, etc. So analyze them now.
declare declare
Prag : Node_Id; Prag : Node_Id;
...@@ -367,9 +366,10 @@ begin ...@@ -367,9 +366,10 @@ begin
end; end;
end if; end if;
-- If we have restriction No_Exception_Propagation, and we did not have an -- If we have restriction No_Exception_Propagation, and we did not have
-- explicit switch turning off Warn_On_Non_Local_Exception, then turn on -- an explicit switch turning off Warn_On_Non_Local_Exception, then turn
-- this warning by default if we have encountered an exception handler. -- on this warning by default if we have encountered an exception
-- handler.
if Restriction_Check_Required (No_Exception_Propagation) if Restriction_Check_Required (No_Exception_Propagation)
and then not No_Warn_On_Non_Local_Exception and then not No_Warn_On_Non_Local_Exception
...@@ -384,7 +384,8 @@ begin ...@@ -384,7 +384,8 @@ begin
-- Install the configuration pragmas in the tree -- Install the configuration pragmas in the tree
Set_Config_Pragmas (Aux_Decls_Node (Cunit (Main_Unit)), Config_Pragmas); Set_Config_Pragmas
(Aux_Decls_Node (Cunit (Main_Unit)), Config_Pragmas);
-- Following steps are skipped if we had a fatal error during parsing -- Following steps are skipped if we had a fatal error during parsing
...@@ -462,6 +463,7 @@ begin ...@@ -462,6 +463,7 @@ begin
Sem_Warn.Output_Unused_Warnings_Off_Warnings; Sem_Warn.Output_Unused_Warnings_Off_Warnings;
end if; end if;
end if; end if;
end;
-- Qualify all entity names in inner packages, package bodies, etc -- Qualify all entity names in inner packages, package bodies, etc
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment