diff options
author | Ed Schonberg <schonberg@adacore.com> | 2018-05-22 13:26:17 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-05-22 13:26:17 +0000 |
commit | 90fa86136a27e147c0bb53434696c2baaba62b41 (patch) | |
tree | 2a05c0a882eca1011afe55917d0307e37f4913dd | |
parent | 3b26fe826601cd43b8a4e7b1b29114034bd3eabb (diff) | |
download | gcc-90fa86136a27e147c0bb53434696c2baaba62b41.zip gcc-90fa86136a27e147c0bb53434696c2baaba62b41.tar.gz gcc-90fa86136a27e147c0bb53434696c2baaba62b41.tar.bz2 |
[Ada] Better error message on illegal 'Access on formal subprogram
This patch improves on the error message for an attempt to apply 'Access
to a formal subprogram. It also applies the check to a renaming of a formal
subprogram.
Compiling p.adb must yield:
p.adb:15:18: not subtype conformant with declaration at line 2
p.adb:15:18: formal subprograms are not subtype conformant (RM 6.3.1 (17/3))
p.adb:16:18: not subtype conformant with declaration at line 2
p.adb:16:18: formal subprograms are not subtype conformant (RM 6.3.1 (17/3))
----
package body P is
procedure Non_Generic (P : access procedure (I : Integer)) is
begin
P.all (5);
end Non_Generic;
procedure G is
procedure Local (I : Integer) is
begin
Action (I);
end;
procedure Local_Action (I : Integer) renames Action;
begin
Non_Generic (Local'access);
Non_Generic (Local_Action'access);
Non_Generic (Action'access);
-- p.adb:15:18: not subtype conformant with declaration at line 2
-- p.adb:15:18: formal subprograms not allowed
end G;
end P;
----
package P is
generic
with procedure Action (I : Integer);
procedure G;
end P;
2018-05-22 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch6.adb (Check_Conformance): Add RM reference for rule that a
formal subprogram is never subtype conformqnt, and thus cannot be the
prefix of 'Access. Reject as well the attribute when applied to a
renaming of a formal subprogram.
From-SVN: r260527
-rw-r--r-- | gcc/ada/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/ada/sem_ch6.adb | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 5a0cf04..7578da1 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2018-05-22 Ed Schonberg <schonberg@adacore.com> + + * sem_ch6.adb (Check_Conformance): Add RM reference for rule that a + formal subprogram is never subtype conformqnt, and thus cannot be the + prefix of 'Access. Reject as well the attribute when applied to a + renaming of a formal subprogram. + 2018-05-22 Hristian Kirtchev <kirtchev@adacore.com> * exp_ch3.adb (Build_Array_Init_Proc): Update the call to diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 55298e9..1fdc2b0 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -5348,9 +5348,13 @@ package body Sem_Ch6 is elsif Is_Formal_Subprogram (Old_Id) or else Is_Formal_Subprogram (New_Id) + or else (Is_Subprogram (New_Id) + and then Present (Alias (New_Id)) + and then Is_Formal_Subprogram (Alias (New_Id))) then - Conformance_Error ("\formal subprograms not allowed!"); - return; + Conformance_Error + ("\formal subprograms are not subtype conformant " + & "(RM 6.3.1 (17/3))"); end if; end if; |