public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix crash on frontend inlining of functions with single returns
@ 2022-07-13 10:02 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-07-13 10:02 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

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

When examining expression of the first declaration of the inlined body
make sure that this declaration is in fact an object declaration.

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

gcc/ada/

	* inline.adb (Has_Single_Return): Add guard for the subsequent
	call to Expression.

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

diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb
--- a/gcc/ada/inline.adb
+++ b/gcc/ada/inline.adb
@@ -4648,6 +4648,7 @@ package body Inline is
          return
            Present (Declarations (N))
              and then Present (First (Declarations (N)))
+             and then Nkind (First (Declarations (N))) = N_Object_Declaration
              and then Entity (Expression (Return_Statement)) =
                         Defining_Identifier (First (Declarations (N)));
       end if;



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

only message in thread, other threads:[~2022-07-13 10:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13 10:02 [Ada] Fix crash on frontend inlining of functions with single returns 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).