public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-875] [Ada] Incorrect code for anonymous access-to-function with convention C
@ 2022-06-01  8:44 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-06-01  8:44 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5512eabc3e162c2c1e4c54febc716353519e51f0

commit r13-875-g5512eabc3e162c2c1e4c54febc716353519e51f0
Author: Bob Duff <duff@adacore.com>
Date:   Thu Apr 28 10:22:42 2022 -0400

    [Ada] Incorrect code for anonymous access-to-function with convention C
    
    This patch fixes a bug where the compiler generates incorrect code for a
    call via an object with convention C, whose type is an anonymous
    access-to-function type.
    
    gcc/ada/
    
            * einfo-utils.adb (Set_Convention): Call Set_Convention
            recursively, so that Set_Can_Use_Internal_Rep is called (if
            appropriate) on the anonymous access type of the object, and its
            designated subprogram type.
            * sem_ch3.adb (Access_Definition): Remove redundant call to
            Set_Can_Use_Internal_Rep.

Diff:
---
 gcc/ada/einfo-utils.adb | 9 ++++-----
 gcc/ada/sem_ch3.adb     | 3 ---
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb
index 48a1bce817d..5e778b127f6 100644
--- a/gcc/ada/einfo-utils.adb
+++ b/gcc/ada/einfo-utils.adb
@@ -2659,7 +2659,7 @@ package body Einfo.Utils is
                             | E_Anonymous_Access_Subprogram_Type
               and then not Has_Convention_Pragma (Typ)
             then
-               Set_Basic_Convention (Typ, Val);
+               Set_Convention (Typ, Val);
                Set_Has_Convention_Pragma (Typ);
 
                --  And for the access subprogram type, deal similarly with the
@@ -2669,10 +2669,9 @@ package body Einfo.Utils is
                   declare
                      Dtype : constant Entity_Id := Designated_Type (Typ);
                   begin
-                     if Ekind (Dtype) = E_Subprogram_Type
-                       and then not Has_Convention_Pragma (Dtype)
-                     then
-                        Set_Basic_Convention (Dtype, Val);
+                     if Ekind (Dtype) = E_Subprogram_Type then
+                        pragma Assert (not Has_Convention_Pragma (Dtype));
+                        Set_Convention (Dtype, Val);
                         Set_Has_Convention_Pragma (Dtype);
                      end if;
                   end;
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 34dac1df624..b7f26a3a066 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -876,9 +876,6 @@ package body Sem_Ch3 is
             Mutate_Ekind (Anon_Type, E_Anonymous_Access_Subprogram_Type);
          end if;
 
-         Set_Can_Use_Internal_Rep
-           (Anon_Type, not Always_Compatible_Rep_On_Target);
-
          --  If the anonymous access is associated with a protected operation,
          --  create a reference to it after the enclosing protected definition
          --  because the itype will be used in the subsequent bodies.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-01  8:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-01  8:44 [gcc r13-875] [Ada] Incorrect code for anonymous access-to-function with convention C Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).