public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] No ABE check needed for an expression function call.
@ 2021-10-01  6:14 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-10-01  6:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: Steve Baird

[-- Attachment #1: Type: text/plain, Size: 776 bytes --]

If -gnatE is specified, then in some cases a call to a subprogram
includes a check that the body of the subprogram has been elaborated. No
such check is needed in the case of an expression function that is not a
completion; the function has no prior declaration. However, in some
cases the compiler was incorrectly treating an expression function
declared in the visible part of a package as though it had a function
body declared within the package body.  Not only could this result in an
unnecessary check, but that check could fail and raise Program_Error.
The ABE check is now correctly omitted.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_elab.adb (Is_Safe_Call): Return True in the case of a
	(possibly rewritten) call to an expression function.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 706 bytes --]

diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb
--- a/gcc/ada/sem_elab.adb
+++ b/gcc/ada/sem_elab.adb
@@ -13621,6 +13621,13 @@ package body Sem_Elab is
       then
          return True;
 
+      --  A call to an expression function that is not a completion cannot
+      --  cause an ABE because it has no prior declaration; this remains
+      --  true even if the FE transforms the callee into something else.
+
+      elsif Nkind (Original_Node (Spec_Decl)) = N_Expression_Function then
+         return True;
+
       --  Subprogram bodies which wrap attribute references used as actuals
       --  in instantiations are always ABE-safe. These bodies are artifacts
       --  of expansion.



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

only message in thread, other threads:[~2021-10-01  6:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01  6:14 [Ada] No ABE check needed for an expression function call 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).