+2018-07-31 Gary Dismukes <dismukes@adacore.com>
+
+ * exp_ch6.adb (Expand_N_Extended_Return_Statement): Replace
+ calls to Current_Scope in three assertions with calls to
+ Current_Subprogram.
+
2018-07-31 Ed Schonberg <schonberg@adacore.com>
* sem_eval.adb (Check_Non_Static_Context): Do not warn on an
-- the pointer to the object) they are always handled by means of
-- simple return statements.
- pragma Assert (not Is_Thunk (Current_Scope));
+ pragma Assert (not Is_Thunk (Current_Subprogram));
if Nkind (Ret_Obj_Decl) = N_Object_Declaration then
Exp := Expression (Ret_Obj_Decl);
-- then F and G are both b-i-p, or neither b-i-p.
if Nkind (Exp) = N_Function_Call then
- pragma Assert (Ekind (Current_Scope) = E_Function);
+ pragma Assert (Ekind (Current_Subprogram) = E_Function);
pragma Assert
- (Is_Build_In_Place_Function (Current_Scope) =
+ (Is_Build_In_Place_Function (Current_Subprogram) =
Is_Build_In_Place_Function_Call (Exp));
null;
end if;
+2018-07-31 Gary Dismukes <dismukes@adacore.com>
+
+ * gnat.dg/block_ext_return_assert_failure.adb: New testcase.
+
2018-07-31 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/iter3.adb: New testcase.
--- /dev/null
+-- { dg-do compile }
+
+-- This test used to crash a compiler with assertions enabled
+
+procedure Block_Ext_Return_Assert_Failure is
+
+ function Return_Int return Integer is
+ begin
+ return 123;
+ end Return_Int;
+
+ function F return Integer is
+ begin
+ declare
+ begin
+ return Result : constant Integer := Return_Int do
+ null;
+ end return;
+ end;
+ end F;
+
+begin
+ null;
+end Block_Ext_Return_Assert_Failure;