diff mbox series

[Ada] Fix crash on frontend inlining of functions with single returns

Message ID 20220713100251.GA994589@adacore.com
State New
Headers show
Series [Ada] Fix crash on frontend inlining of functions with single returns | expand

Commit Message

Pierre-Marie de Rodat July 13, 2022, 10:02 a.m. UTC
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.
diff mbox series

Patch

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;