]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Spurious error on function returning CPP type
authorJavier Miranda <miranda@adacore.com>
Fri, 27 Jan 2023 13:19:25 +0000 (13:19 +0000)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 16 May 2023 08:30:58 +0000 (10:30 +0200)
gcc/ada/

* exp_ch6.adb
(Needs_BIP_Alloc_Form): Return False for functions with foreign
convention since we never use build-in-place for such functions.

gcc/ada/exp_ch6.adb

index af7f75342fa5d5bdcc2d9dc6be2f25d944f1edc9..b8e5a720a7cdc18fbeb37bf4b8e858de5ed47525 100644 (file)
@@ -9435,9 +9435,14 @@ package body Exp_Ch6 is
       --  types, and those can be used to call primitives, so the formal needs
       --  to be passed to all such build-in-place functions, primitive or not.
 
+      --  We never use build-in-place if the function has foreign convention,
+      --  but note that it is OK for a build-in-place function to return a
+      --  type with a foreign convention because the machinery ensures there
+      --  is no copying.
+
       return not Restriction_Active (No_Secondary_Stack)
         and then (Needs_Secondary_Stack (Typ) or else Is_Tagged_Type (Typ))
-        and then not Has_Foreign_Convention (Typ);
+        and then not Has_Foreign_Convention (Func_Id);
    end Needs_BIP_Alloc_Form;
 
    -------------------------------------