aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorJustin Squirek <squirek@adacore.com>2018-05-24 13:05:32 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-05-24 13:05:32 +0000
commitc06a59be1990743d1520b89016a532572a9256ab (patch)
tree9737fecf2ea356b3edff25e5d218e47d3f7f82d1 /gcc/ada
parentfa3717c173192eb04440734a3ee110982f31e592 (diff)
downloadgcc-c06a59be1990743d1520b89016a532572a9256ab.zip
gcc-c06a59be1990743d1520b89016a532572a9256ab.tar.gz
gcc-c06a59be1990743d1520b89016a532572a9256ab.tar.bz2
[Ada] Crash on return of raise expression
This patch fixes an issue whereby the compiler regarded assignments to limited that consisted of raise expressions to be a compile-time error during expansion. 2018-05-24 Justin Squirek <squirek@adacore.com> gcc/ada/ * exp_ch3.adb (Expand_N_Object_Declaration): Ignore raising an error in expansion for limited tagged types when the node to be expanded is a raise expression due to it not representing a valid object. * exp_ch5.adb (Expand_N_Assignment_Statement): Add exception to error message regarding assignments to limited types to ignore genereated code. gcc/testsuite/ * gnat.dg/raise_expr.adb: New testcase. From-SVN: r260654
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog9
-rw-r--r--gcc/ada/exp_ch3.adb6
-rw-r--r--gcc/ada/exp_ch5.adb11
3 files changed, 22 insertions, 4 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index bf69dbf..e0ea459 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,12 @@
+2018-05-24 Justin Squirek <squirek@adacore.com>
+
+ * exp_ch3.adb (Expand_N_Object_Declaration): Ignore raising an error in
+ expansion for limited tagged types when the node to be expanded is a
+ raise expression due to it not representing a valid object.
+ * exp_ch5.adb (Expand_N_Assignment_Statement): Add exception to error
+ message regarding assignments to limited types to ignore genereated
+ code.
+
2018-05-24 Hristian Kirtchev <kirtchev@adacore.com>
* exp_util.adb (New_Class_Wide_Subtype): Capture and restore relevant
diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index 4c5d940..4c3a7b7 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -6952,9 +6952,11 @@ package body Exp_Ch3 is
-- If we cannot convert the expression into a renaming we must
-- consider it an internal error because the backend does not
- -- have support to handle it.
+ -- have support to handle it. Also, when a raise expression is
+ -- encountered we ignore it since it doesn't return a value and
+ -- thus cannot trigger a copy.
- else
+ elsif Nkind (Original_Node (Expr_Q)) /= N_Raise_Expression then
pragma Assert (False);
raise Program_Error;
end if;
diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
index 81fb162..0989370 100644
--- a/gcc/ada/exp_ch5.adb
+++ b/gcc/ada/exp_ch5.adb
@@ -2467,12 +2467,19 @@ package body Exp_Ch5 is
-- extension of a limited interface, and the actual is
-- limited. This is an error according to AI05-0087, but
-- is not caught at the point of instantiation in earlier
- -- versions.
+ -- versions. We also must verify that the limited type does
+ -- not come from source as corner cases may exist where
+ -- an assignment was not intended like the pathological case
+ -- of a raise expression within a return statement.
-- This is wrong, error messages cannot be issued during
-- expansion, since they would be missed in -gnatc mode ???
- Error_Msg_N ("assignment not available on limited type", N);
+ if Comes_From_Source (N) then
+ Error_Msg_N
+ ("assignment not available on limited type", N);
+ end if;
+
return;
end if;