public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-10] Fortran : ICE for division by zero in declaration PR95882
@ 2020-09-01 10:00 Tobias Burnus
0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2020-09-01 10:00 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:8323d09e82345a1ca39f6630cdd22ccf4ef38a84
commit 8323d09e82345a1ca39f6630cdd22ccf4ef38a84
Author: Mark Eggleston <markeggleston@gcc.gnu.org>
Date: Fri Aug 21 06:39:30 2020 +0100
Fortran : ICE for division by zero in declaration PR95882
A length expression containing a divide by zero in a character
declaration will result in an ICE if the constant is anymore
complicated that a contant divided by a constant.
The cause was that char_len_param_value can return MATCH_YES
even if a divide by zero was seen. Prior to returning check
whether a divide by zero was seen and if so set it to MATCH_ERROR.
2020-08-27 Mark Eggleston <markeggleston@gcc.gnu.org>
gcc/fortran
PR fortran/95882
* decl.c (char_len_param_value): Check gfc_seen_div0 and
if it is set return MATCH_ERROR.
2020-08-27 Mark Eggleston <markeggleston@gcc.gnu.org>
gcc/testsuite/
PR fortran/95882
* gfortran.dg/pr95882_1.f90: New test.
* gfortran.dg/pr95882_2.f90: New test.
* gfortran.dg/pr95882_3.f90: New test.
* gfortran.dg/pr95882_4.f90: New test.
* gfortran.dg/pr95882_5.f90: New test.
(cherry picked from commit c336eda750d4e7a0827fedf995da955d6d88d5ca)
Diff:
---
gcc/fortran/decl.c | 3 +++
gcc/testsuite/gfortran.dg/pr95882_1.f90 | 8 ++++++++
gcc/testsuite/gfortran.dg/pr95882_2.f90 | 6 ++++++
gcc/testsuite/gfortran.dg/pr95882_3.f90 | 6 ++++++
gcc/testsuite/gfortran.dg/pr95882_4.f90 | 7 +++++++
gcc/testsuite/gfortran.dg/pr95882_5.f90 | 6 ++++++
6 files changed, 36 insertions(+)
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 36326f77569..e6c500bf8d2 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -1146,6 +1146,9 @@ char_len_param_value (gfc_expr **expr, bool *deferred)
gfc_free_expr (e);
}
+ if (gfc_seen_div0)
+ m = MATCH_ERROR;
+
return m;
syntax:
diff --git a/gcc/testsuite/gfortran.dg/pr95882_1.f90 b/gcc/testsuite/gfortran.dg/pr95882_1.f90
new file mode 100644
index 00000000000..c254bddf494
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95882_1.f90
@@ -0,0 +1,8 @@
+! { dg-do compile }
+
+module m
+ type t
+ character(((0)/0)) :: c ! { dg-error "Division by zero" }
+ end type
+end
+
diff --git a/gcc/testsuite/gfortran.dg/pr95882_2.f90 b/gcc/testsuite/gfortran.dg/pr95882_2.f90
new file mode 100644
index 00000000000..d308f0c3181
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95882_2.f90
@@ -0,0 +1,6 @@
+! { dg-do compile }
+
+module m
+ character(0/(0)) :: c = '123456789' ! { dg-error "Division by zero" }
+end
+
diff --git a/gcc/testsuite/gfortran.dg/pr95882_3.f90 b/gcc/testsuite/gfortran.dg/pr95882_3.f90
new file mode 100644
index 00000000000..bd849135480
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95882_3.f90
@@ -0,0 +1,6 @@
+! { dg-do compile }
+
+subroutine s(c)
+ character(((0)/0)) :: c ! { dg-error "Division by zero" }
+end
+
diff --git a/gcc/testsuite/gfortran.dg/pr95882_4.f90 b/gcc/testsuite/gfortran.dg/pr95882_4.f90
new file mode 100644
index 00000000000..52892d32b8b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95882_4.f90
@@ -0,0 +1,7 @@
+! { dg-do compile }
+
+program p
+ character(((0)/0)) :: c ! { dg-error "Division by zero" }
+ common /x/ c
+end
+
diff --git a/gcc/testsuite/gfortran.dg/pr95882_5.f90 b/gcc/testsuite/gfortran.dg/pr95882_5.f90
new file mode 100644
index 00000000000..dcdf5304052
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95882_5.f90
@@ -0,0 +1,6 @@
+! { dg-do compile }
+
+program p
+ character(0/(0)) :: c = '123456789' ! { dg-error "Division by zero" }
+ common c
+end
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-01 10:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 10:00 [gcc/devel/omp/gcc-10] Fortran : ICE for division by zero in declaration PR95882 Tobias Burnus
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).