diff options
author | Bob Duff <duff@adacore.com> | 2017-01-06 11:56:16 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-01-06 12:56:16 +0100 |
commit | 533e3abc48268dd8eee0c63ddcf133e7a14b370d (patch) | |
tree | e8e7f4a54bb69880fbcb93c3100b1f285bc23820 /gcc/ada/sinfo.adb | |
parent | a62e6287d91309dd07957739d5a000fc0b0073c9 (diff) | |
download | gcc-533e3abc48268dd8eee0c63ddcf133e7a14b370d.zip gcc-533e3abc48268dd8eee0c63ddcf133e7a14b370d.tar.gz gcc-533e3abc48268dd8eee0c63ddcf133e7a14b370d.tar.bz2 |
snames.ads-tmpl (Renamed): New name for the pragma argument.
2017-01-06 Bob Duff <duff@adacore.com>
* snames.ads-tmpl (Renamed): New name for the pragma argument.
* par-ch2.adb: Allow the new pragma (with analysis deferred
to Sem_Prag).
* sinfo.ads, sinfo.adb (Map_Pragma_Name, Pragma_Name_Mapped):
Keep a mapping from new pragma names to old names.
* sem_prag.adb: Check legality of pragma Rename_Pragma, and
implement it by calling Map_Pragma_Name.
* checks.adb, contracts.adb, einfo.adb, errout.adb,
* exp_attr.adb, exp_ch3.adb, exp_ch6.adb, exp_ch7.adb, exp_ch9.adb,
* exp_prag.adb, exp_util.adb, freeze.adb, frontend.adb, ghost.adb,
* inline.adb, lib-writ.adb, scans.adb, scans.ads, sem_attr.adb,
* sem_aux.adb, sem_ch10.adb, sem_ch13.adb, sem_ch6.adb, sem_ch9.adb,
* sem_elab.adb, sem_res.adb, sem_util.adb, sem_util.ads,
* sem_warn.adb: Call Pragma_Name_Mapped instead of Pragma_Name
as appropriate.
From-SVN: r244144
Diffstat (limited to 'gcc/ada/sinfo.adb')
-rw-r--r-- | gcc/ada/sinfo.adb | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/gcc/ada/sinfo.adb b/gcc/ada/sinfo.adb index 30960b4..4059f21 100644 --- a/gcc/ada/sinfo.adb +++ b/gcc/ada/sinfo.adb @@ -6822,9 +6822,28 @@ package body Sinfo is -- Map_Pragma_Name -- --------------------- + -- We don't want to introduce a dependence on some hash table package or + -- similar, so we use a simple array of Key => Value pairs, and do a linear + -- search. Linear search is plenty efficient, given that we don't expect + -- more than a couple of entries in the mapping. + + type Name_Pair is record + Key : Name_Id; + Value : Name_Id; + end record; + + type Pragma_Map_Index is range 1 .. 100; + Pragma_Map : array (Pragma_Map_Index) of Name_Pair; + Last_Pair : Pragma_Map_Index'Base range 0 .. Pragma_Map_Index'Last := 0; + procedure Map_Pragma_Name (From, To : Name_Id) is begin - null; -- not yet implemented + if Last_Pair = Pragma_Map'Last then + raise Too_Many_Pragma_Mappings; + end if; + + Last_Pair := Last_Pair + 1; + Pragma_Map (Last_Pair) := (Key => From, Value => To); end Map_Pragma_Name; ------------------------ @@ -6832,8 +6851,15 @@ package body Sinfo is ------------------------ function Pragma_Name_Mapped (N : Node_Id) return Name_Id is + Result : constant Name_Id := Pragma_Name (N); begin - return Pragma_Name (N); + for J in Pragma_Map'Range loop + if Result = Pragma_Map (J).Key then + return Pragma_Map (J).Value; + end if; + end loop; + + return Result; end Pragma_Name_Mapped; end Sinfo; |