aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorGary Dismukes <dismukes@adacore.com>2018-07-31 09:55:53 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-07-31 09:55:53 +0000
commit76ed5f08f4462d7d22bc6cda3624e131e65bdd52 (patch)
tree054114f442c2e9e2489c8dd2bcb09c35b7aaed8f /gcc/ada
parentc4a2e585d3b4e829f48fcb3c2a825584890b4fda (diff)
downloadgcc-76ed5f08f4462d7d22bc6cda3624e131e65bdd52.zip
gcc-76ed5f08f4462d7d22bc6cda3624e131e65bdd52.tar.gz
gcc-76ed5f08f4462d7d22bc6cda3624e131e65bdd52.tar.bz2
[Ada] Compiler failure on an extended_return_statement in a block
When compiling with an assertion-enabled compiler, Assert_Failure can be raised when expanded an extended_return_statement whose enclosing scope is not a function (such as when it's a block_statement). The simple fix is to change the Assert to test Current_Subprogram rather than Current_Scope. Three such Assert pragmas are corrected in this way. 2018-07-31 Gary Dismukes <dismukes@adacore.com> gcc/ada/ * exp_ch6.adb (Expand_N_Extended_Return_Statement): Replace calls to Current_Scope in three assertions with calls to Current_Subprogram. gcc/testsuite/ * gnat.dg/block_ext_return_assert_failure.adb: New testcase. From-SVN: r263096
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/exp_ch6.adb6
2 files changed, 9 insertions, 3 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 8b28605..f8da47c 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index 2ac5db6..f71cdab 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -4763,7 +4763,7 @@ package body Exp_Ch6 is
-- 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);
@@ -4772,9 +4772,9 @@ package body Exp_Ch6 is
-- 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;