diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
commit | e252b51ccde010cbd2a146485d8045103cd99533 (patch) | |
tree | e060f101cdc32bf5e520de8e5275db9d4236b74c /gcc/ada/lib-xref.adb | |
parent | f10c7c4596dda99d2ee872c995ae4aeda65adbdf (diff) | |
parent | 104c05c5284b7822d770ee51a7d91946c7e56d50 (diff) | |
download | gcc-e252b51ccde010cbd2a146485d8045103cd99533.zip gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.gz gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.bz2 |
Merge from trunk revision 104c05c5284b7822d770ee51a7d91946c7e56d50.
Diffstat (limited to 'gcc/ada/lib-xref.adb')
-rw-r--r-- | gcc/ada/lib-xref.adb | 89 |
1 files changed, 57 insertions, 32 deletions
diff --git a/gcc/ada/lib-xref.adb b/gcc/ada/lib-xref.adb index 0869906..17de886 100644 --- a/gcc/ada/lib-xref.adb +++ b/gcc/ada/lib-xref.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1998-2020, Free Software Foundation, Inc. -- +-- Copyright (C) 1998-2021, 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- -- @@ -23,26 +23,30 @@ -- -- ------------------------------------------------------------------------------ -with Atree; use Atree; -with Csets; use Csets; -with Elists; use Elists; -with Errout; use Errout; -with Lib.Util; use Lib.Util; -with Nlists; use Nlists; -with Opt; use Opt; -with Restrict; use Restrict; -with Rident; use Rident; -with Sem; use Sem; -with Sem_Aux; use Sem_Aux; -with Sem_Prag; use Sem_Prag; -with Sem_Util; use Sem_Util; -with Sem_Warn; use Sem_Warn; -with Sinfo; use Sinfo; -with Sinput; use Sinput; -with Snames; use Snames; -with Stringt; use Stringt; -with Stand; use Stand; -with Table; use Table; +with Atree; use Atree; +with Csets; use Csets; +with Einfo; use Einfo; +with Einfo.Utils; use Einfo.Utils; +with Elists; use Elists; +with Errout; use Errout; +with Lib.Util; use Lib.Util; +with Nlists; use Nlists; +with Opt; use Opt; +with Restrict; use Restrict; +with Rident; use Rident; +with Sem; use Sem; +with Sem_Aux; use Sem_Aux; +with Sem_Prag; use Sem_Prag; +with Sem_Util; use Sem_Util; +with Sem_Warn; use Sem_Warn; +with Sinfo; use Sinfo; +with Sinfo.Nodes; use Sinfo.Nodes; +with Sinfo.Utils; use Sinfo.Utils; +with Sinput; use Sinput; +with Snames; use Snames; +with Stringt; use Stringt; +with Stand; use Stand; +with Table; use Table; with GNAT.Heap_Sort_G; with GNAT.HTable; @@ -699,6 +703,37 @@ package body Lib.Xref is Error_Msg_NE ("& is only defined in Ada 2012?y?", N, E); end if; + -- Warn if reference to Ada 2022 entity not in Ada 2022 mode. We only + -- detect real explicit references (modifications and references). + + if Comes_From_Source (N) + and then Is_Ada_2022_Only (E) + and then not Is_Subprogram (E) + and then Ada_Version < Ada_2022 + and then Warn_On_Ada_2022_Compatibility + and then (Typ = 'm' or else Typ = 'r') + then + Error_Msg_NE ("& is only defined in Ada 2022?y?", N, E); + + -- Error on static and dispatching calls to Ada 2022 subprograms that + -- require overriding if we are not in Ada 2022 mode (since overriding + -- was skipped); warn if the subprogram does not require overriding. + + elsif Comes_From_Source (N) + and then Is_Ada_2022_Only (E) + and then Ada_Version < Ada_2022 + and then Is_Subprogram (E) + and then (Typ = 'r' or else Typ = 's' or else Typ = 'R') + then + if Requires_Overriding (E) then + Error_Msg_NE + ("& is only defined in Ada 2022 and requires overriding", N, E); + + elsif Warn_On_Ada_2022_Compatibility then + Error_Msg_NE ("& is only defined in Ada 2022?y?", N, E); + end if; + end if; + -- Do not generate references if we are within a postcondition sub- -- program, because the reference does not comes from source, and the -- preanalysis of the aspect has already created an entry for the ALI @@ -1277,18 +1312,8 @@ package body Lib.Xref is Formal : Entity_Id; begin - if Is_Generic_Subprogram (E) then - Formal := First_Entity (E); - - while Present (Formal) - and then not Is_Formal (Formal) - loop - Next_Entity (Formal); - end loop; - - elsif Ekind (E) in Access_Subprogram_Kind then + if Is_Access_Subprogram_Type (E) then Formal := First_Formal (Designated_Type (E)); - else Formal := First_Formal (E); end if; |