Commit 28bc3323 by Arnaud Charlet

[multiple changes]

2014-06-13  Robert Dewar  <dewar@adacore.com>

	* back_end.adb (Make_Id): New function.
	(Make_SC): New function.
	(Set_RND): New procedure.
	* back_end.ads (Make_Id): New function.
	(Make_SC): New function.
	(Set_RND): New procedure.
	* einfo.ads: Minor comment updates.
	* frontend.adb: Move Atree.Initialize call to Gnat1drv.
	* gnat1drv.adb (Gnat1drv): New calling sequence for
	Get_Target_Parameters.
	(Gnat1drv): Move Atree.Initialize here from Frontend.
	* targparm.adb (Get_Target_Parameters): New calling
	sequence (Get_Target_Parameters): Handle pragma Restriction
	(No_Dependence,..)
	* targparm.ads (Get_Target_Parameters): New calling sequence.

2014-06-13  Gary Dismukes  <dismukes@adacore.com>

	* sem_prag.adb (Process_Import_Or_Interface): Exit the homonym
	loop if the pragma does not come from source, so that an implicit
	pragma Import only applies to the first declaration, avoiding
	possible conflicts with earlier explicit and implicit declarations
	due to multiple Provide_Shift_Operators pragmas.
	(Set_Imported): Remove previous fix that bypassed pragma duplication
	error.
	* gnat_rm.texi: Change 'equivalent' to 'similar' in description
	of Provide_Shift_Operators.

From-SVN: r211610
parent ca6cbdca
2014-06-13 Robert Dewar <dewar@adacore.com>
* back_end.adb (Make_Id): New function.
(Make_SC): New function.
(Set_RND): New procedure.
* back_end.ads (Make_Id): New function.
(Make_SC): New function.
(Set_RND): New procedure.
* einfo.ads: Minor comment updates.
* frontend.adb: Move Atree.Initialize call to Gnat1drv.
* gnat1drv.adb (Gnat1drv): New calling sequence for
Get_Target_Parameters.
(Gnat1drv): Move Atree.Initialize here from Frontend.
* targparm.adb (Get_Target_Parameters): New calling
sequence (Get_Target_Parameters): Handle pragma Restriction
(No_Dependence,..)
* targparm.ads (Get_Target_Parameters): New calling sequence.
2014-06-13 Gary Dismukes <dismukes@adacore.com>
* sem_prag.adb (Process_Import_Or_Interface): Exit the homonym
loop if the pragma does not come from source, so that an implicit
pragma Import only applies to the first declaration, avoiding
possible conflicts with earlier explicit and implicit declarations
due to multiple Provide_Shift_Operators pragmas.
(Set_Imported): Remove previous fix that bypassed pragma duplication
error.
* gnat_rm.texi: Change 'equivalent' to 'similar' in description
of Provide_Shift_Operators.
2014-06-12 Jan Hubicka <hubicka@ucw.cz> 2014-06-12 Jan Hubicka <hubicka@ucw.cz>
* gcc-interface/utils.c (process_attributes) <ATTR_LINK_SECTION>: Pass * gcc-interface/utils.c (process_attributes) <ATTR_LINK_SECTION>: Pass
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2014, 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- --
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Atree; use Atree; with Atree; use Atree;
with Csets; use Csets;
with Debug; use Debug; with Debug; use Debug;
with Elists; use Elists; with Elists; use Elists;
with Errout; use Errout; with Errout; use Errout;
...@@ -33,13 +34,14 @@ with Opt; use Opt; ...@@ -33,13 +34,14 @@ with Opt; use Opt;
with Osint.C; use Osint.C; with Osint.C; use Osint.C;
with Namet; use Namet; with Namet; use Namet;
with Nlists; use Nlists; with Nlists; use Nlists;
with Nmake; use Nmake;
with Restrict; use Restrict;
with Stand; use Stand; with Stand; use Stand;
with Sinput; use Sinput; with Sinput; use Sinput;
with Stringt; use Stringt; with Stringt; use Stringt;
with Switch; use Switch; with Switch; use Switch;
with Switch.C; use Switch.C; with Switch.C; use Switch.C;
with System; use System; with System; use System;
with Types; use Types;
with System.OS_Lib; use System.OS_Lib; with System.OS_Lib; use System.OS_Lib;
...@@ -163,6 +165,15 @@ package body Back_End is ...@@ -163,6 +165,15 @@ package body Back_End is
gigi_operating_mode => Mode); gigi_operating_mode => Mode);
end Call_Back_End; end Call_Back_End;
-------------------------------
-- Gen_Or_Update_Object_File --
-------------------------------
procedure Gen_Or_Update_Object_File is
begin
null;
end Gen_Or_Update_Object_File;
------------- -------------
-- Len_Arg -- -- Len_Arg --
------------- -------------
...@@ -178,6 +189,36 @@ package body Back_End is ...@@ -178,6 +189,36 @@ package body Back_End is
raise Program_Error; raise Program_Error;
end Len_Arg; end Len_Arg;
-------------
-- Make_Id --
-------------
function Make_Id (Str : Text_Buffer) return Node_Id is
begin
Name_Len := 0;
for J in Str'Range loop
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := Fold_Lower (Str (J));
end loop;
return
Make_Identifier (System_Location,
Chars => Name_Find);
end Make_Id;
-------------
-- Make_SC --
-------------
function Make_SC (Pre, Sel : Node_Id) return Node_Id is
begin
return
Make_Selected_Component (System_Location,
Prefix => Pre,
Selector_Name => Sel);
end Make_SC;
----------------------------- -----------------------------
-- Scan_Compiler_Arguments -- -- Scan_Compiler_Arguments --
----------------------------- -----------------------------
...@@ -342,13 +383,13 @@ package body Back_End is ...@@ -342,13 +383,13 @@ package body Back_End is
end loop; end loop;
end Scan_Compiler_Arguments; end Scan_Compiler_Arguments;
------------------------------- -------------
-- Gen_Or_Update_Object_File -- -- Set_RND --
------------------------------- -------------
procedure Gen_Or_Update_Object_File is procedure Set_RND (Unit : Node_Id) is
begin begin
null; Restrict.Set_Restriction_No_Dependence (Unit, Warn => False);
end Gen_Or_Update_Object_File; end Set_RND;
end Back_End; end Back_End;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2014, 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- --
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- Call the back end with all the information needed -- Call the back end with all the information needed
-- Note: there are multiple bodies/variants of this package, so do not
-- modify this spec without coordination.
with Types; use Types;
package Back_End is package Back_End is
...@@ -82,4 +86,13 @@ package Back_End is ...@@ -82,4 +86,13 @@ package Back_End is
-- object file's timestamp is correct when compared with the corresponding -- object file's timestamp is correct when compared with the corresponding
-- ali file by gnatmake. -- ali file by gnatmake.
function Make_Id (Str : Text_Buffer) return Node_Id;
function Make_SC (Pre, Sel : Node_Id) return Node_Id;
procedure Set_RND (Unit : Node_Id);
-- Subprograms for call to Get_Target_Parameters, see spec of package
-- Targparm for full description of these three subprograms. These are
-- parked in this package because they are have to be at the top level
-- because of accessibility issues, and Gnat1drv, which is where they
-- are used, is a subprogram.
end Back_End; end Back_End;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2014, 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- --
...@@ -80,7 +80,6 @@ begin ...@@ -80,7 +80,6 @@ begin
-- since it uses names table entries. -- since it uses names table entries.
Rtsfind.Initialize; Rtsfind.Initialize;
Atree.Initialize;
Nlists.Initialize; Nlists.Initialize;
Elists.Initialize; Elists.Initialize;
Lib.Load.Initialize; Lib.Load.Initialize;
......
...@@ -81,6 +81,10 @@ with Validsw; use Validsw; ...@@ -81,6 +81,10 @@ with Validsw; use Validsw;
with System.Assertions; with System.Assertions;
--------------
-- Gnat1drv --
--------------
procedure Gnat1drv is procedure Gnat1drv is
Main_Unit_Node : Node_Id; Main_Unit_Node : Node_Id;
-- Compilation unit node for main unit -- Compilation unit node for main unit
...@@ -763,6 +767,7 @@ begin ...@@ -763,6 +767,7 @@ begin
Scan_Compiler_Arguments; Scan_Compiler_Arguments;
Osint.Add_Default_Search_Dirs; Osint.Add_Default_Search_Dirs;
Atree.Initialize;
Nlists.Initialize; Nlists.Initialize;
Sinput.Initialize; Sinput.Initialize;
Sem.Initialize; Sem.Initialize;
...@@ -785,7 +790,7 @@ begin ...@@ -785,7 +790,7 @@ begin
-- Acquire target parameters from system.ads (source of package System) -- Acquire target parameters from system.ads (source of package System)
declare Targparm_Acquire : declare
use Sinput; use Sinput;
S : Source_File_Index; S : Source_File_Index;
...@@ -812,12 +817,17 @@ begin ...@@ -812,12 +817,17 @@ begin
Targparm.Get_Target_Parameters Targparm.Get_Target_Parameters
(System_Text => Source_Text (S), (System_Text => Source_Text (S),
Source_First => Source_First (S), Source_First => Source_First (S),
Source_Last => Source_Last (S)); Source_Last => Source_Last (S),
Make_Id => Back_End.Make_Id'Unrestricted_Access,
Make_SC => Back_End.Make_SC'Unrestricted_Access,
Set_RND => Back_End.Set_RND'Unrestricted_Access);
-- Acquire configuration pragma information from Targparm -- Acquire configuration pragma information from Targparm
Restrict.Restrictions := Targparm.Restrictions_On_Target; Restrict.Restrictions := Targparm.Restrictions_On_Target;
end; end Targparm_Acquire;
-- Perform various adjustments and settings of global switches
Adjust_Global_Switches; Adjust_Global_Switches;
......
...@@ -5852,7 +5852,7 @@ pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME); ...@@ -5852,7 +5852,7 @@ pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
This pragma can be applied to a first subtype local name that specifies This pragma can be applied to a first subtype local name that specifies
either an unsigned or signed type. It has the effect of providing the either an unsigned or signed type. It has the effect of providing the
five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic, five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
Rotate_Left and Rotate_Right) for the given type. It is equivalent to Rotate_Left and Rotate_Right) for the given type. It is similar to
including the function declarations for these five operators, together including the function declarations for these five operators, together
with the pragma Import (Intrinsic, ...) statements. with the pragma Import (Intrinsic, ...) statements.
......
...@@ -8066,7 +8066,8 @@ package body Sem_Prag is ...@@ -8066,7 +8066,8 @@ package body Sem_Prag is
then then
-- If the name is overloaded, pragma applies to all of the denoted -- If the name is overloaded, pragma applies to all of the denoted
-- entities in the same declarative part, unless the pragma comes -- entities in the same declarative part, unless the pragma comes
-- from an aspect specification. -- from an aspect specification or was generated by the compiler
-- (such as for pragma Provide_Shift_Operators).
Hom_Id := Def_Id; Hom_Id := Def_Id;
while Present (Hom_Id) loop while Present (Hom_Id) loop
...@@ -8178,6 +8179,19 @@ package body Sem_Prag is ...@@ -8178,6 +8179,19 @@ package body Sem_Prag is
elsif From_Aspect_Specification (N) then elsif From_Aspect_Specification (N) then
exit; exit;
-- If the pragma was created by the compiler, then we don't
-- want it to apply to other homonyms. This kind of case can
-- occur when using pragma Provide_Shift_Operators, which
-- generates implicit shift and rotate operators with Import
-- pragmas that might apply to earlier explicit or implicit
-- declarations marked with Import (for example, coming from
-- an earlier pragma Provide_Shift_Operators for another type),
-- and we don't generally want other homonyms being treated
-- as imported or the pragma flagged as an illegal duplicate.
elsif not Comes_From_Source (N) then
exit;
else else
Hom_Id := Homonym (Hom_Id); Hom_Id := Homonym (Hom_Id);
end if; end if;
...@@ -9576,12 +9590,6 @@ package body Sem_Prag is ...@@ -9576,12 +9590,6 @@ package body Sem_Prag is
elsif Import_Interface_Present (N) then elsif Import_Interface_Present (N) then
goto OK; goto OK;
-- OK if the pragma was expanded by the compiler. Can occur when
-- using pragma Provide_Shift_Operators on multiple types.
elsif not Comes_From_Source (N) then
goto OK;
-- Error if being set Imported twice -- Error if being set Imported twice
else else
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1999-2013, Free Software Foundation, Inc. -- -- Copyright (C) 1999-2014, 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- --
...@@ -160,7 +160,11 @@ package body Targparm is ...@@ -160,7 +160,11 @@ package body Targparm is
-- Version which reads in system.ads -- Version which reads in system.ads
procedure Get_Target_Parameters is procedure Get_Target_Parameters
(Make_Id : Make_Id_Type := null;
Make_SC : Make_SC_Type := null;
Set_RND : Set_RND_Type := null)
is
Text : Source_Buffer_Ptr; Text : Source_Buffer_Ptr;
Hi : Source_Ptr; Hi : Source_Ptr;
...@@ -183,7 +187,10 @@ package body Targparm is ...@@ -183,7 +187,10 @@ package body Targparm is
Get_Target_Parameters Get_Target_Parameters
(System_Text => Text, (System_Text => Text,
Source_First => 0, Source_First => 0,
Source_Last => Hi); Source_Last => Hi,
Make_Id => Make_Id,
Make_SC => Make_SC,
Set_RND => Set_RND);
end Get_Target_Parameters; end Get_Target_Parameters;
-- Version where caller supplies system.ads text -- Version where caller supplies system.ads text
...@@ -191,7 +198,10 @@ package body Targparm is ...@@ -191,7 +198,10 @@ package body Targparm is
procedure Get_Target_Parameters procedure Get_Target_Parameters
(System_Text : Source_Buffer_Ptr; (System_Text : Source_Buffer_Ptr;
Source_First : Source_Ptr; Source_First : Source_Ptr;
Source_Last : Source_Ptr) Source_Last : Source_Ptr;
Make_Id : Make_Id_Type := null;
Make_SC : Make_SC_Type := null;
Set_RND : Set_RND_Type := null)
is is
P : Source_Ptr; P : Source_Ptr;
-- Scans source buffer containing source of system.ads -- Scans source buffer containing source of system.ads
...@@ -341,6 +351,61 @@ package body Targparm is ...@@ -341,6 +351,61 @@ package body Targparm is
null; null;
end loop Ploop; end loop Ploop;
-- No_Dependence case
if System_Text (P .. P + 16) = "No_Dependence => " then
P := P + 17;
-- Skip this processing (and simply ignore No_Dependence lines)
-- if caller did not supply the three subprograms we need to
-- process these lines.
if Make_Id = null then
goto Line_Loop_Continue;
end if;
-- We have scanned out "pragma Restrictions (No_Dependence =>"
declare
Unit : Node_Id;
Id : Node_Id;
Start : Source_Ptr;
begin
Unit := Empty;
-- Loop through components of name, building up Unit
loop
Start := P;
while System_Text (P) /= '.'
and then
System_Text (P) /= ')'
loop
P := P + 1;
end loop;
Id := Make_Id (System_Text (Start .. P - 1));
-- If first name, just capture the identifier
if Unit = Empty then
Unit := Id;
else
Unit := Make_SC (Unit, Id);
end if;
exit when System_Text (P) = ')';
P := P + 1;
end loop;
Set_RND (Unit);
goto Line_Loop_Continue;
end;
end if;
-- Here if unrecognizable restrictions pragma form
Set_Standard_Error; Set_Standard_Error;
Write_Line Write_Line
("fatal error: system.ads is incorrectly formatted"); ("fatal error: system.ads is incorrectly formatted");
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1999-2013, Free Software Foundation, Inc. -- -- Copyright (C) 1999-2014, 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- --
...@@ -612,17 +612,42 @@ package Targparm is ...@@ -612,17 +612,42 @@ package Targparm is
-- These subprograms are used to initialize the target parameter values -- These subprograms are used to initialize the target parameter values
-- from the system.ads file. Note that this is only done once, so if more -- from the system.ads file. Note that this is only done once, so if more
-- than one call is made to either routine, the second and subsequent -- than one call is made to either routine, the second and subsequent
-- calls are ignored. -- calls are ignored. It also reads restriction pragmas from system.ads
-- and records them, though as further detailed below, the caller has some
-- control over the handling of No_Dependence restrictions.
type Make_Id_Type is access function (Str : Text_Buffer) return Node_Id;
-- Parameter type for Get_Target_Parameters for function that creates an
-- identifier node with Sloc value System_Location and given string as the
-- Chars value.
type Make_SC_Type is access function (Pre, Sel : Node_Id) return Node_Id;
-- Parameter type for Get_Target_Parameters for function that creates a
-- selected component with Sloc value System_Location and given Prefix
-- (Pre) and Selector (Sel) values.
type Set_RND_Type is access procedure (Unit : Node_Id);
-- Parameter type for Get_Target_Parameters that records a Restriction
-- No_Dependence for the given unit (identifier or selected component).
procedure Get_Target_Parameters procedure Get_Target_Parameters
(System_Text : Source_Buffer_Ptr; (System_Text : Source_Buffer_Ptr;
Source_First : Source_Ptr; Source_First : Source_Ptr;
Source_Last : Source_Ptr); Source_Last : Source_Ptr;
Make_Id : Make_Id_Type := null;
Make_SC : Make_SC_Type := null;
Set_RND : Set_RND_Type := null);
-- Called at the start of execution to obtain target parameters from -- Called at the start of execution to obtain target parameters from
-- the source of package System. The parameters provide the source -- the source of package System. The parameters provide the source
-- text to be scanned (in System_Text (Source_First .. Source_Last)). -- text to be scanned (in System_Text (Source_First .. Source_Last)).
-- if the three subprograms are left at their default value of null,
-- Get_Target_Parameters will ignore pragma Restrictions No_Dependence
-- lines, otherwise it will use these three subprograms to record them.
procedure Get_Target_Parameters; procedure Get_Target_Parameters
(Make_Id : Make_Id_Type := null;
Make_SC : Make_SC_Type := null;
Set_RND : Set_RND_Type := null);
-- This version reads in system.ads using Osint. The idea is that the -- This version reads in system.ads using Osint. The idea is that the
-- caller uses the first version if they have to read system.ads anyway -- caller uses the first version if they have to read system.ads anyway
-- (e.g. the compiler) and uses this simpler interface if system.ads is -- (e.g. the compiler) and uses this simpler interface if system.ads is
......
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