summaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-14 15:11:17 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-14 15:11:17 +0000
commit073c96a605648f274d4e0e4bf16f4833bcfd524b (patch)
tree5b92aa98aad961b67cdefffbc0c12ff912bfdcd0 /gcc/fortran
parent3a23a641423aed45840766437d4553c1a8795eba (diff)
downloadgcc-073c96a605648f274d4e0e4bf16f4833bcfd524b.tar.gz
2007-12-14 Tobias Burnus <burnus@net-b.de>
PR fortran/34398 * expr.c (gfc_check_assign): Add range checks for assignments of * BOZs. * resolve.c (resolve_ordinary_assign): Ditto. * arith.c (gfc_range_check): Fix return value for complex * numbers. 2007-12-14 Tobias Burnus <burnus@net-b.de> PR fortran/34398 * gfortran.dg/nan_4.f90: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130932 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/arith.c6
-rw-r--r--gcc/fortran/expr.c17
-rw-r--r--gcc/fortran/resolve.c17
4 files changed, 46 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 1000705a2fb..40bbc53385d 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,10 @@
+2007-12-14 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/34398
+ * expr.c (gfc_check_assign): Add range checks for assignments of BOZs.
+ * resolve.c (resolve_ordinary_assign): Ditto.
+ * arith.c (gfc_range_check): Fix return value for complex numbers.
+
2007-12-14 Daniel Franke <franke.daniel@gmail.com>
PR fortran/34324
diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c
index 01d2989f316..b06aa078c8a 100644
--- a/gcc/fortran/arith.c
+++ b/gcc/fortran/arith.c
@@ -532,6 +532,7 @@ arith
gfc_range_check (gfc_expr *e)
{
arith rc;
+ arith rc2;
switch (e->ts.type)
{
@@ -558,13 +559,16 @@ gfc_range_check (gfc_expr *e)
if (rc == ARITH_NAN)
mpfr_set_nan (e->value.complex.r);
- rc = gfc_check_real_range (e->value.complex.i, e->ts.kind);
+ rc2 = gfc_check_real_range (e->value.complex.i, e->ts.kind);
if (rc == ARITH_UNDERFLOW)
mpfr_set_ui (e->value.complex.i, 0, GFC_RND_MODE);
if (rc == ARITH_OVERFLOW)
mpfr_set_inf (e->value.complex.i, mpfr_sgn (e->value.complex.i));
if (rc == ARITH_NAN)
mpfr_set_nan (e->value.complex.i);
+
+ if (rc == ARITH_OK)
+ rc = rc2;
break;
default:
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 255acb6f188..92ad77e37a4 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -2755,11 +2755,28 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rvalue, int conform)
/* Handle the case of a BOZ literal on the RHS. */
if (rvalue->is_boz && lvalue->ts.type != BT_INTEGER)
{
+ int rc;
if (gfc_option.warn_surprising)
gfc_warning ("BOZ literal at %L is bitwise transferred "
"non-integer symbol '%s'", &rvalue->where,
lvalue->symtree->n.sym->name);
gfc_convert_boz (rvalue, &lvalue->ts);
+ if ((rc = gfc_range_check (rvalue)) != ARITH_OK)
+ {
+ if (rc == ARITH_UNDERFLOW)
+ gfc_error ("Arithmetic underflow of bit-wise transferred BOZ at %L"
+ ". This check can be disabled with the option "
+ "-fno-range-check", &rvalue->where);
+ else if (rc == ARITH_OVERFLOW)
+ gfc_error ("Arithmetic overflow of bit-wise transferred BOZ at %L"
+ ". This check can be disabled with the option "
+ "-fno-range-check", &rvalue->where);
+ else if (rc == ARITH_NAN)
+ gfc_error ("Arithmetic NaN of bit-wise transferred BOZ at %L"
+ ". This check can be disabled with the option "
+ "-fno-range-check", &rvalue->where);
+ return FAILURE;
+ }
}
if (gfc_compare_types (&lvalue->ts, &rvalue->ts))
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index c5b95b46a04..bee74e53c42 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -5921,12 +5921,29 @@ resolve_ordinary_assign (gfc_code *code, gfc_namespace *ns)
/* Handle the case of a BOZ literal on the RHS. */
if (rhs->is_boz && lhs->ts.type != BT_INTEGER)
{
+ int rc;
if (gfc_option.warn_surprising)
gfc_warning ("BOZ literal at %L is bitwise transferred "
"non-integer symbol '%s'", &code->loc,
lhs->symtree->n.sym->name);
gfc_convert_boz (rhs, &lhs->ts);
+ if ((rc = gfc_range_check (rhs)) != ARITH_OK)
+ {
+ if (rc == ARITH_UNDERFLOW)
+ gfc_error ("Arithmetic underflow of bit-wise transferred BOZ at %L"
+ ". This check can be disabled with the option "
+ "-fno-range-check", &rhs->where);
+ else if (rc == ARITH_OVERFLOW)
+ gfc_error ("Arithmetic overflow of bit-wise transferred BOZ at %L"
+ ". This check can be disabled with the option "
+ "-fno-range-check", &rhs->where);
+ else if (rc == ARITH_NAN)
+ gfc_error ("Arithmetic NaN of bit-wise transferred BOZ at %L"
+ ". This check can be disabled with the option "
+ "-fno-range-check", &rhs->where);
+ return false;
+ }
}