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>
* sem_warn.adb (Warn_On_Suspicious_Index): Improve warning when the
......
......@@ -3934,9 +3934,9 @@ package body Exp_Ch5 is
function Get_Default_Iterator
(T : Entity_Id) return Entity_Id;
-- If the container is a derived type, the aspect holds the parent
-- operation. The required one is a primitive of the derived type
-- and is either inherited or overridden. Also sets Container_Arg.
-- Return the default iterator for a specific type. If the type is
-- derived, we return the inherited or overridden one if
-- appropriate.
--------------------------
-- Get_Default_Iterator --
......@@ -3953,11 +3953,11 @@ package body Exp_Ch5 is
begin
Container_Arg := New_Copy_Tree (Container);
-- A previous version of GNAT allowed indexing aspects to
-- be redefined on derived container types, while the
-- default iterator was inherited from the parent type.
-- This non-standard extension is preserved temporarily for
-- use by the modelling project under debug flag d.X.
-- A previous version of GNAT allowed indexing aspects to be
-- redefined on derived container types, while the default
-- iterator was inherited from the parent type. This
-- nonstandard extension is preserved for use by the
-- modelling project under debug flag -gnatd.X.
if Debug_Flag_Dot_XX then
if Base_Type (Etype (Container)) /=
......@@ -3995,9 +3995,11 @@ package body Exp_Ch5 is
Next_Elmt (Prim);
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
......
......@@ -6,7 +6,7 @@
-- --
-- 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 --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -68,9 +68,6 @@ with Tbuild; use Tbuild;
with Types; use Types;
procedure Frontend is
Config_Pragmas : List_Id;
-- Gather configuration pragmas
begin
-- Carry out package initializations. These are initializations which might
-- logically be performed at elaboration time, were it not for the fact
......@@ -136,6 +133,12 @@ begin
-- Read and process configuration pragma files if present
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 mode so it can be restored later
......@@ -144,8 +147,6 @@ begin
Prag : Node_Id;
Temp_File : Boolean;
begin
-- We always analyze config files with style checks off, since we
-- don't want a miscellaneous gnat.adc that is around to discombobulate
......@@ -162,9 +163,7 @@ begin
-- First deal with gnat.adc file
if Opt.Config_File then
Name_Buffer (1 .. 8) := "gnat.adc";
Name_Len := 8;
Source_gnat_adc := Load_Config_File (Name_Enter);
Source_gnat_adc := Load_Config_File (Gnat_Adc);
-- Case of gnat.adc file present
......@@ -175,20 +174,11 @@ begin
Initialize_Scanner (No_Unit, Source_gnat_adc);
Config_Pragmas := Par (Configuration_Pragmas => True);
-- We unconditionally add a compilation dependency for gnat.adc
-- so that if it changes, we force a recompilation. This is a
-- fairly recent (2014-03-28) change.
-- We add a compilation dependency for gnat.adc so that if it
-- changes, we force a recompilation.
Prepcomp.Add_Dependency (Source_gnat_adc);
-- Case of no gnat.adc file present
else
Config_Pragmas := Empty_List;
end if;
else
Config_Pragmas := Empty_List;
end if;
-- Now deal with specified config pragmas files if there are any
......@@ -198,32 +188,38 @@ begin
-- Loop through config pragmas files
for Index in Opt.Config_File_Names'Range loop
-- See if extension is .TMP/.tmp indicating a temporary config
-- file (which we ignore from the dependency point of view).
Name_Len := Config_File_Names (Index)'Length;
Name_Buffer (1 .. Name_Len) := Config_File_Names (Index).all;
Temp_File :=
Name_Len > 4
declare
Len : constant Natural := Config_File_Names (Index)'Length;
Str : constant String (1 .. Len) :=
Config_File_Names (Index).all;
Config_Name : constant File_Name_Type := Name_Find (Str);
Temp_File : constant Boolean := Len > 4
and then
(Name_Buffer (Name_Len - 3 .. Name_Len) = ".TMP"
(Str (Len - 3 .. Len) = ".TMP"
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
Source_Config_File := Load_Config_File (Name_Enter);
Source_Config_File := Load_Config_File (Config_Name);
if Source_Config_File = No_Source_File then
Osint.Fail
("cannot find configuration pragmas file "
& Config_File_Names (Index).all);
-- If we did find the file, and it is not a temporary file, then
-- we unconditionally add a compilation dependency for it so
-- that if it changes, we force a recompilation. This is a
-- fairly recent (2014-03-28) change.
-- If we did find the file, and it is not a temporary file,
-- then we add a compilation dependency for it so that if it
-- changes, we force a recompilation.
elsif not Temp_File then
Prepcomp.Add_Dependency (Source_Config_File);
......@@ -234,6 +230,8 @@ begin
Initialize_Scanner (No_Unit, Source_Config_File);
Append_List_To
(Config_Pragmas, Par (Configuration_Pragmas => True));
end if;
end;
end loop;
end if;
......@@ -260,10 +258,9 @@ begin
-- Capture any modifications to suppress options from config pragmas
Opt.Suppress_Options := Scope_Suppress;
end;
-- If a target dependency info file has been read through switch -gnateT=,
-- add it to the dependencies.
-- If a target dependency info file has been read through switch
-- -gnateT=, add it to the dependencies.
if Target_Dependent_Info_Read_Name /= null then
declare
......@@ -276,14 +273,15 @@ begin
end;
end if;
-- This is where we can capture the value of the compilation unit specific
-- restrictions that have been set by the config pragma files (or from
-- Targparm), for later restoration when processing e.g. subunits.
-- This is where we can capture the value of the compilation unit
-- specific restrictions that have been set by the config pragma
-- files (or from Targparm), for later restoration when processing
-- e.g. subunits.
Save_Config_Cunit_Boolean_Restrictions;
-- If there was a -gnatem switch, initialize the mappings of unit names to
-- file names and of file names to path names from the mapping file.
-- If there was a -gnatem switch, initialize the mappings of unit names
-- to file names and of file names to path names from the mapping file.
if Mapping_File_Name /= null then
Fmap.Initialize (Mapping_File_Name.all);
......@@ -297,9 +295,10 @@ begin
Optimize_Alignment := 'T';
end if;
-- We have now processed the command line switches, and the configuration
-- pragma files, so this is the point at which we want to capture the
-- values of the configuration switches (see Opt for further details).
-- We have now processed the command line switches, and the
-- configuration pragma files, so this is the point at which we want to
-- capture the values of the configuration switches (see Opt for further
-- details).
Opt.Register_Opt_Config_Switches;
......@@ -334,16 +333,16 @@ begin
if Config_Pragmas /= Error_List
and then Operating_Mode /= Check_Syntax
-- Do not attempt to process deferred configuration pragmas if the main
-- unit failed to load, to avoid cascaded inconsistencies that can lead
-- to a compiler crash.
-- Do not attempt to process deferred configuration pragmas if the
-- main unit failed to load, to avoid cascaded inconsistencies that
-- can lead to a compiler crash.
and then Fatal_Error (Main_Unit) /= Error_Detected
then
-- Pragmas that require some semantic activity, such as Interrupt_State,
-- cannot be processed until the main unit is installed, because they
-- require a compilation unit on which to attach with_clauses, etc. So
-- analyze them now.
-- Pragmas that require some semantic activity, such as
-- Interrupt_State, cannot be processed until the main unit is
-- installed, because they require a compilation unit on which to
-- attach with_clauses, etc. So analyze them now.
declare
Prag : Node_Id;
......@@ -367,9 +366,10 @@ begin
end;
end if;
-- If we have restriction No_Exception_Propagation, and we did not have an
-- explicit switch turning off Warn_On_Non_Local_Exception, then turn on
-- this warning by default if we have encountered an exception handler.
-- If we have restriction No_Exception_Propagation, and we did not have
-- an explicit switch turning off Warn_On_Non_Local_Exception, then turn
-- on this warning by default if we have encountered an exception
-- handler.
if Restriction_Check_Required (No_Exception_Propagation)
and then not No_Warn_On_Non_Local_Exception
......@@ -384,7 +384,8 @@ begin
-- 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
......@@ -462,6 +463,7 @@ begin
Sem_Warn.Output_Unused_Warnings_Off_Warnings;
end if;
end if;
end;
-- 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