diff options
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; |