|
|
d0de29 |
From 79bc3c8c15122dd929703f5ca7e468ffd46c3c3e Mon Sep 17 00:00:00 2001
|
|
|
d0de29 |
From: Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
d0de29 |
Date: Mon, 9 Apr 2018 15:10:02 +0100
|
|
|
d0de29 |
Subject: [PATCH 12/16] Support type promotion in calls to intrinsics
|
|
|
d0de29 |
|
|
|
d0de29 |
Use -fdec-promotion or -fdec to enable this feature.
|
|
|
d0de29 |
|
|
|
d0de29 |
Merged 2 commits: worked on by Ben Brewer <ben.brewer@codethink.co.uk>,
|
|
|
d0de29 |
Francisco Redondo Marchena
|
|
|
d0de29 |
Jeff Law <law@redhat.com>
|
|
|
d0de29 |
|
|
|
d0de29 |
Re-worked by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
---
|
|
|
d0de29 |
gcc/fortran/check.c | 71 +++++-
|
|
|
d0de29 |
gcc/fortran/intrinsic.c | 5 +
|
|
|
d0de29 |
gcc/fortran/iresolve.c | 91 ++++---
|
|
|
d0de29 |
gcc/fortran/lang.opt | 4 +
|
|
|
d0de29 |
gcc/fortran/options.c | 1 +
|
|
|
d0de29 |
gcc/fortran/simplify.c | 266 ++++++++++++++++-----
|
|
|
d0de29 |
...ec_intrinsic_int_real_array_const_promotion_1.f | 18 ++
|
|
|
d0de29 |
...ec_intrinsic_int_real_array_const_promotion_2.f | 18 ++
|
|
|
d0de29 |
...ec_intrinsic_int_real_array_const_promotion_3.f | 18 ++
|
|
|
d0de29 |
.../dec_intrinsic_int_real_const_promotion_1.f | 90 +++++++
|
|
|
d0de29 |
.../dec_intrinsic_int_real_const_promotion_2.f | 90 +++++++
|
|
|
d0de29 |
.../dec_intrinsic_int_real_const_promotion_3.f | 92 +++++++
|
|
|
d0de29 |
.../dec_intrinsic_int_real_promotion_1.f | 130 ++++++++++
|
|
|
d0de29 |
.../dec_intrinsic_int_real_promotion_2.f | 130 ++++++++++
|
|
|
d0de29 |
.../dec_intrinsic_int_real_promotion_3.f | 130 ++++++++++
|
|
|
d0de29 |
.../dec_intrinsic_int_real_promotion_4.f | 118 +++++++++
|
|
|
d0de29 |
.../dec_intrinsic_int_real_promotion_5.f | 118 +++++++++
|
|
|
d0de29 |
.../dec_intrinsic_int_real_promotion_6.f | 118 +++++++++
|
|
|
d0de29 |
.../dec_intrinsic_int_real_promotion_7.f | 118 +++++++++
|
|
|
d0de29 |
gcc/testsuite/gfortran.dg/dec_kind_promotion-1.f | 40 ++++
|
|
|
d0de29 |
gcc/testsuite/gfortran.dg/dec_kind_promotion-2.f | 40 ++++
|
|
|
d0de29 |
gcc/testsuite/gfortran.dg/dec_kind_promotion-3.f | 40 ++++
|
|
|
d0de29 |
22 files changed, 1655 insertions(+), 91 deletions(-)
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_1.f
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_2.f
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_3.f
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_1.f
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_2.f
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_3.f
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_1.f
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_2.f
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_3.f
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_4.f
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_5.f
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_6.f
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_7.f
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_kind_promotion-1.f
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_kind_promotion-2.f
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_kind_promotion-3.f
|
|
|
d0de29 |
|
|
|
d0de29 |
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
|
|
|
d0de29 |
index 0ba4d0a031f..89416ba368d 100644
|
|
|
d0de29 |
--- a/gcc/fortran/check.c
|
|
|
d0de29 |
+++ b/gcc/fortran/check.c
|
|
|
d0de29 |
@@ -947,12 +947,40 @@ gfc_check_allocated (gfc_expr *array)
|
|
|
d0de29 |
}
|
|
|
d0de29 |
|
|
|
d0de29 |
|
|
|
d0de29 |
+/* Check function where both arguments must be real or integer
|
|
|
d0de29 |
+ and warn if they are different types. */
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+bool
|
|
|
d0de29 |
+check_int_real_promotion (gfc_expr *a, gfc_expr *b)
|
|
|
d0de29 |
+{
|
|
|
d0de29 |
+ gfc_expr *i;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ if (!int_or_real_check (a, 0))
|
|
|
d0de29 |
+ return false;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ if (!int_or_real_check (b, 1))
|
|
|
d0de29 |
+ return false;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ if (a->ts.type != b->ts.type)
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ i = (a->ts.type != BT_REAL ? a : b);
|
|
|
d0de29 |
+ gfc_warning_now (OPT_Wconversion, "Conversion from INTEGER to REAL "
|
|
|
d0de29 |
+ "at %L might lose precision", &i->where);
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ return true;
|
|
|
d0de29 |
+}
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+
|
|
|
d0de29 |
/* Common check function where the first argument must be real or
|
|
|
d0de29 |
integer and the second argument must be the same as the first. */
|
|
|
d0de29 |
|
|
|
d0de29 |
bool
|
|
|
d0de29 |
gfc_check_a_p (gfc_expr *a, gfc_expr *p)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
+ if (flag_dec_promotion)
|
|
|
d0de29 |
+ return check_int_real_promotion (a, p);
|
|
|
d0de29 |
+
|
|
|
d0de29 |
if (!int_or_real_check (a, 0))
|
|
|
d0de29 |
return false;
|
|
|
d0de29 |
|
|
|
d0de29 |
@@ -3126,6 +3154,41 @@ check_rest (bt type, int kind, gfc_actual_arglist *arglist)
|
|
|
d0de29 |
}
|
|
|
d0de29 |
|
|
|
d0de29 |
|
|
|
d0de29 |
+/* Check function where all arguments of an argument list must be real
|
|
|
d0de29 |
+ or integer. */
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+static bool
|
|
|
d0de29 |
+check_rest_int_real (gfc_actual_arglist *arglist)
|
|
|
d0de29 |
+{
|
|
|
d0de29 |
+ gfc_actual_arglist *arg, *tmp;
|
|
|
d0de29 |
+ gfc_expr *x;
|
|
|
d0de29 |
+ int m, n;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ if (!min_max_args (arglist))
|
|
|
d0de29 |
+ return false;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ for (arg = arglist, n=1; arg; arg = arg->next, n++)
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ x = arg->expr;
|
|
|
d0de29 |
+ if (x->ts.type != BT_INTEGER && x->ts.type != BT_REAL)
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ gfc_error ("%<a%d%> argument of %qs intrinsic at %L must be "
|
|
|
d0de29 |
+ "INTEGER or REAL", n, gfc_current_intrinsic, &x->where);
|
|
|
d0de29 |
+ return false;
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ for (tmp = arglist, m=1; tmp != arg; tmp = tmp->next, m++)
|
|
|
d0de29 |
+ if (!gfc_check_conformance (tmp->expr, x,
|
|
|
d0de29 |
+ "arguments 'a%d' and 'a%d' for "
|
|
|
d0de29 |
+ "intrinsic '%s'", m, n,
|
|
|
d0de29 |
+ gfc_current_intrinsic))
|
|
|
d0de29 |
+ return false;
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ return true;
|
|
|
d0de29 |
+}
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+
|
|
|
d0de29 |
bool
|
|
|
d0de29 |
gfc_check_min_max (gfc_actual_arglist *arg)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
@@ -3150,7 +3213,10 @@ gfc_check_min_max (gfc_actual_arglist *arg)
|
|
|
d0de29 |
return false;
|
|
|
d0de29 |
}
|
|
|
d0de29 |
|
|
|
d0de29 |
- return check_rest (x->ts.type, x->ts.kind, arg);
|
|
|
d0de29 |
+ if (flag_dec_promotion && x->ts.type != BT_CHARACTER)
|
|
|
d0de29 |
+ return check_rest_int_real (arg);
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ return check_rest (x->ts.type, x->ts.kind, arg);
|
|
|
d0de29 |
}
|
|
|
d0de29 |
|
|
|
d0de29 |
|
|
|
d0de29 |
@@ -4488,6 +4554,9 @@ gfc_check_shift (gfc_expr *i, gfc_expr *shift)
|
|
|
d0de29 |
bool
|
|
|
d0de29 |
gfc_check_sign (gfc_expr *a, gfc_expr *b)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
+ if (flag_dec_promotion)
|
|
|
d0de29 |
+ return check_int_real_promotion (a, b);
|
|
|
d0de29 |
+
|
|
|
d0de29 |
if (!int_or_real_check (a, 0))
|
|
|
d0de29 |
return false;
|
|
|
d0de29 |
|
|
|
d0de29 |
diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
|
|
|
d0de29 |
index 6d47ae3105f..a4b23bc244a 100644
|
|
|
d0de29 |
--- a/gcc/fortran/intrinsic.c
|
|
|
d0de29 |
+++ b/gcc/fortran/intrinsic.c
|
|
|
d0de29 |
@@ -4329,6 +4329,11 @@ check_arglist (gfc_actual_arglist **ap, gfc_intrinsic_sym *sym,
|
|
|
d0de29 |
if (ts.kind == 0)
|
|
|
d0de29 |
ts.kind = actual->expr->ts.kind;
|
|
|
d0de29 |
|
|
|
d0de29 |
+ /* If kind promotion is allowed don't check for kind if it is smaller */
|
|
|
d0de29 |
+ if (flag_dec_promotion && ts.type == BT_INTEGER)
|
|
|
d0de29 |
+ if (actual->expr->ts.kind < ts.kind)
|
|
|
d0de29 |
+ ts.kind = actual->expr->ts.kind;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
if (!gfc_compare_types (&ts, &actual->expr->ts))
|
|
|
d0de29 |
{
|
|
|
d0de29 |
if (error_flag)
|
|
|
d0de29 |
diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
|
|
|
d0de29 |
index 53338dda0a7..92d50c3deb9 100644
|
|
|
d0de29 |
--- a/gcc/fortran/iresolve.c
|
|
|
d0de29 |
+++ b/gcc/fortran/iresolve.c
|
|
|
d0de29 |
@@ -893,19 +893,22 @@ gfc_resolve_dble (gfc_expr *f, gfc_expr *a)
|
|
|
d0de29 |
void
|
|
|
d0de29 |
gfc_resolve_dim (gfc_expr *f, gfc_expr *a, gfc_expr *p)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
- f->ts.type = a->ts.type;
|
|
|
d0de29 |
if (p != NULL)
|
|
|
d0de29 |
- f->ts.kind = gfc_kind_max (a,p);
|
|
|
d0de29 |
- else
|
|
|
d0de29 |
- f->ts.kind = a->ts.kind;
|
|
|
d0de29 |
-
|
|
|
d0de29 |
- if (p != NULL && a->ts.kind != p->ts.kind)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
- if (a->ts.kind == gfc_kind_max (a,p))
|
|
|
d0de29 |
- gfc_convert_type (p, &a->ts, 2);
|
|
|
d0de29 |
+ f->ts.kind = gfc_kind_max (a,p);
|
|
|
d0de29 |
+ if (a->ts.type == BT_REAL || p->ts.type == BT_REAL)
|
|
|
d0de29 |
+ f->ts.type = BT_REAL;
|
|
|
d0de29 |
else
|
|
|
d0de29 |
- gfc_convert_type (a, &p->ts, 2);
|
|
|
d0de29 |
+ f->ts.type = BT_INTEGER;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ if (a->ts.kind != f->ts.kind || a->ts.type != f->ts.type)
|
|
|
d0de29 |
+ gfc_convert_type (a, &f->ts, 2);
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ if (p->ts.kind != f->ts.kind || p->ts.type != f->ts.type)
|
|
|
d0de29 |
+ gfc_convert_type (p, &f->ts, 2);
|
|
|
d0de29 |
}
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ f->ts = a->ts;
|
|
|
d0de29 |
|
|
|
d0de29 |
f->value.function.name
|
|
|
d0de29 |
= gfc_get_string ("__dim_%c%d", gfc_type_letter (f->ts.type), f->ts.kind);
|
|
|
d0de29 |
@@ -1669,14 +1672,17 @@ gfc_resolve_minmax (const char *name, gfc_expr *f, gfc_actual_arglist *args)
|
|
|
d0de29 |
/* Find the largest type kind. */
|
|
|
d0de29 |
for (a = args->next; a; a = a->next)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
+ if (a->expr-> ts.type == BT_REAL)
|
|
|
d0de29 |
+ f->ts.type = BT_REAL;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
if (a->expr->ts.kind > f->ts.kind)
|
|
|
d0de29 |
f->ts.kind = a->expr->ts.kind;
|
|
|
d0de29 |
}
|
|
|
d0de29 |
|
|
|
d0de29 |
- /* Convert all parameters to the required kind. */
|
|
|
d0de29 |
+ /* Convert all parameters to the required type and/or kind. */
|
|
|
d0de29 |
for (a = args; a; a = a->next)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
- if (a->expr->ts.kind != f->ts.kind)
|
|
|
d0de29 |
+ if (a->expr->ts.type != f->ts.type || a->expr->ts.kind != f->ts.kind)
|
|
|
d0de29 |
gfc_convert_type (a->expr, &f->ts, 2);
|
|
|
d0de29 |
}
|
|
|
d0de29 |
|
|
|
d0de29 |
@@ -2169,19 +2175,22 @@ gfc_resolve_minval (gfc_expr *f, gfc_expr *array, gfc_expr *dim,
|
|
|
d0de29 |
void
|
|
|
d0de29 |
gfc_resolve_mod (gfc_expr *f, gfc_expr *a, gfc_expr *p)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
- f->ts.type = a->ts.type;
|
|
|
d0de29 |
if (p != NULL)
|
|
|
d0de29 |
- f->ts.kind = gfc_kind_max (a,p);
|
|
|
d0de29 |
- else
|
|
|
d0de29 |
- f->ts.kind = a->ts.kind;
|
|
|
d0de29 |
-
|
|
|
d0de29 |
- if (p != NULL && a->ts.kind != p->ts.kind)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
- if (a->ts.kind == gfc_kind_max (a,p))
|
|
|
d0de29 |
- gfc_convert_type (p, &a->ts, 2);
|
|
|
d0de29 |
+ f->ts.kind = gfc_kind_max (a,p);
|
|
|
d0de29 |
+ if (a->ts.type == BT_REAL || p->ts.type == BT_REAL)
|
|
|
d0de29 |
+ f->ts.type = BT_REAL;
|
|
|
d0de29 |
else
|
|
|
d0de29 |
- gfc_convert_type (a, &p->ts, 2);
|
|
|
d0de29 |
+ f->ts.type = BT_INTEGER;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ if (a->ts.kind != f->ts.kind || a->ts.type != f->ts.type)
|
|
|
d0de29 |
+ gfc_convert_type (a, &f->ts, 2);
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ if (p->ts.kind != f->ts.kind || p->ts.type != f->ts.type)
|
|
|
d0de29 |
+ gfc_convert_type (p, &f->ts, 2);
|
|
|
d0de29 |
}
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ f->ts = a->ts;
|
|
|
d0de29 |
|
|
|
d0de29 |
f->value.function.name
|
|
|
d0de29 |
= gfc_get_string ("__mod_%c%d", gfc_type_letter (f->ts.type), f->ts.kind);
|
|
|
d0de29 |
@@ -2191,19 +2200,22 @@ gfc_resolve_mod (gfc_expr *f, gfc_expr *a, gfc_expr *p)
|
|
|
d0de29 |
void
|
|
|
d0de29 |
gfc_resolve_modulo (gfc_expr *f, gfc_expr *a, gfc_expr *p)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
- f->ts.type = a->ts.type;
|
|
|
d0de29 |
if (p != NULL)
|
|
|
d0de29 |
- f->ts.kind = gfc_kind_max (a,p);
|
|
|
d0de29 |
- else
|
|
|
d0de29 |
- f->ts.kind = a->ts.kind;
|
|
|
d0de29 |
-
|
|
|
d0de29 |
- if (p != NULL && a->ts.kind != p->ts.kind)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
- if (a->ts.kind == gfc_kind_max (a,p))
|
|
|
d0de29 |
- gfc_convert_type (p, &a->ts, 2);
|
|
|
d0de29 |
+ f->ts.kind = gfc_kind_max (a,p);
|
|
|
d0de29 |
+ if (a->ts.type == BT_REAL || p->ts.type == BT_REAL)
|
|
|
d0de29 |
+ f->ts.type = BT_REAL;
|
|
|
d0de29 |
else
|
|
|
d0de29 |
- gfc_convert_type (a, &p->ts, 2);
|
|
|
d0de29 |
+ f->ts.type = BT_INTEGER;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ if (a->ts.kind != f->ts.kind || a->ts.type != f->ts.type)
|
|
|
d0de29 |
+ gfc_convert_type (a, &f->ts, 2);
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ if (p->ts.kind != f->ts.kind || p->ts.type != f->ts.type)
|
|
|
d0de29 |
+ gfc_convert_type (p, &f->ts, 2);
|
|
|
d0de29 |
}
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ f->ts = a->ts;
|
|
|
d0de29 |
|
|
|
d0de29 |
f->value.function.name
|
|
|
d0de29 |
= gfc_get_string ("__modulo_%c%d", gfc_type_letter (f->ts.type),
|
|
|
d0de29 |
@@ -2578,9 +2590,26 @@ gfc_resolve_shift (gfc_expr *f, gfc_expr *i, gfc_expr *shift ATTRIBUTE_UNUSED)
|
|
|
d0de29 |
|
|
|
d0de29 |
|
|
|
d0de29 |
void
|
|
|
d0de29 |
-gfc_resolve_sign (gfc_expr *f, gfc_expr *a, gfc_expr *b ATTRIBUTE_UNUSED)
|
|
|
d0de29 |
+gfc_resolve_sign (gfc_expr *f, gfc_expr *a, gfc_expr *b)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
- f->ts = a->ts;
|
|
|
d0de29 |
+ if (b != NULL)
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ f->ts.kind = gfc_kind_max (a, b);
|
|
|
d0de29 |
+ if (a->ts.type == BT_REAL || b->ts.type == BT_REAL)
|
|
|
d0de29 |
+ f->ts.type = BT_REAL;
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ f->ts.type = BT_INTEGER;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ if (a->ts.kind != f->ts.kind || a->ts.type != f->ts.type)
|
|
|
d0de29 |
+ gfc_convert_type (a, &f->ts, 2);
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ if (b->ts.kind != f->ts.kind || b->ts.type != f->ts.type)
|
|
|
d0de29 |
+ gfc_convert_type (b, &f->ts, 2);
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ f->ts = a->ts;
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
f->value.function.name
|
|
|
d0de29 |
= gfc_get_string ("__sign_%c%d", gfc_type_letter (a->ts.type), a->ts.kind);
|
|
|
d0de29 |
}
|
|
|
d0de29 |
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
|
|
|
d0de29 |
index fa2851ae837..2a8f5f661a8 100644
|
|
|
d0de29 |
--- a/gcc/fortran/lang.opt
|
|
|
d0de29 |
+++ b/gcc/fortran/lang.opt
|
|
|
d0de29 |
@@ -490,6 +490,10 @@ fdec-old-init
|
|
|
d0de29 |
Fortran Var(flag_dec_old_init)
|
|
|
d0de29 |
Enable support for old style initializers in derived types.
|
|
|
d0de29 |
|
|
|
d0de29 |
+fdec-promotion
|
|
|
d0de29 |
+Fortran Var(flag_dec_promotion)
|
|
|
d0de29 |
+Add support for type promotion in intrinsic arguments.
|
|
|
d0de29 |
+
|
|
|
d0de29 |
fdec-structure
|
|
|
d0de29 |
Fortran Var(flag_dec_structure)
|
|
|
d0de29 |
Enable support for DEC STRUCTURE/RECORD.
|
|
|
d0de29 |
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
|
|
|
d0de29 |
index 7b04a681f7b..7a2583a2076 100644
|
|
|
d0de29 |
--- a/gcc/fortran/options.c
|
|
|
d0de29 |
+++ b/gcc/fortran/options.c
|
|
|
d0de29 |
@@ -83,6 +83,7 @@ set_dec_flags (int value)
|
|
|
d0de29 |
SET_BITFLAG (flag_dec_old_init, value, value);
|
|
|
d0de29 |
SET_BITFLAG (flag_dec_override_kind, value, value);
|
|
|
d0de29 |
SET_BITFLAG (flag_dec_non_logical_if, value, value);
|
|
|
d0de29 |
+ SET_BITFLAG (flag_dec_promotion, value, value);
|
|
|
d0de29 |
}
|
|
|
d0de29 |
|
|
|
d0de29 |
/* Finalize DEC flags. */
|
|
|
d0de29 |
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
|
|
|
d0de29 |
index 7aff256c6b3..cb5f93e293d 100644
|
|
|
d0de29 |
--- a/gcc/fortran/simplify.c
|
|
|
d0de29 |
+++ b/gcc/fortran/simplify.c
|
|
|
d0de29 |
@@ -2256,39 +2256,79 @@ gfc_simplify_digits (gfc_expr *x)
|
|
|
d0de29 |
}
|
|
|
d0de29 |
|
|
|
d0de29 |
|
|
|
d0de29 |
+/* Simplify function which sets the floating-point value of ar from
|
|
|
d0de29 |
+ the value of a independently if a is integer of real. */
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+static void
|
|
|
d0de29 |
+simplify_int_real_promotion (const gfc_expr *a, const gfc_expr *b, mpfr_t *ar)
|
|
|
d0de29 |
+{
|
|
|
d0de29 |
+ if (a->ts.type == BT_REAL)
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ mpfr_init2 (*ar, (a->ts.kind * 8));
|
|
|
d0de29 |
+ mpfr_set (*ar, a->value.real, GFC_RND_MODE);
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ mpfr_init2 (*ar, (b->ts.kind * 8));
|
|
|
d0de29 |
+ mpfr_set_z (*ar, a->value.integer, GFC_RND_MODE);
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+}
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+/* Simplify function which promotes a and b arguments from integer to real if
|
|
|
d0de29 |
+ required in ar and br floating-point values. This function returns true if
|
|
|
d0de29 |
+ a or b are reals and false otherwise. */
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+static bool
|
|
|
d0de29 |
+simplify_int_real_promotion2 (const gfc_expr *a, const gfc_expr *b, mpfr_t *ar,
|
|
|
d0de29 |
+ mpfr_t *br)
|
|
|
d0de29 |
+{
|
|
|
d0de29 |
+ if (a->ts.type != BT_REAL && b->ts.type != BT_REAL)
|
|
|
d0de29 |
+ return false;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ simplify_int_real_promotion (a, b, ar);
|
|
|
d0de29 |
+ simplify_int_real_promotion (b, a, br);
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ return true;
|
|
|
d0de29 |
+}
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+
|
|
|
d0de29 |
gfc_expr *
|
|
|
d0de29 |
gfc_simplify_dim (gfc_expr *x, gfc_expr *y)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
gfc_expr *result;
|
|
|
d0de29 |
int kind;
|
|
|
d0de29 |
|
|
|
d0de29 |
+ mpfr_t xr;
|
|
|
d0de29 |
+ mpfr_t yr;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
if (x->expr_type != EXPR_CONSTANT || y->expr_type != EXPR_CONSTANT)
|
|
|
d0de29 |
return NULL;
|
|
|
d0de29 |
|
|
|
d0de29 |
- kind = x->ts.kind > y->ts.kind ? x->ts.kind : y->ts.kind;
|
|
|
d0de29 |
- result = gfc_get_constant_expr (x->ts.type, kind, &x->where);
|
|
|
d0de29 |
-
|
|
|
d0de29 |
- switch (x->ts.type)
|
|
|
d0de29 |
+ if ((x->ts.type != BT_REAL && x->ts.type != BT_INTEGER)
|
|
|
d0de29 |
+ || (y->ts.type != BT_REAL && y->ts.type != BT_INTEGER))
|
|
|
d0de29 |
{
|
|
|
d0de29 |
- case BT_INTEGER:
|
|
|
d0de29 |
- if (mpz_cmp (x->value.integer, y->value.integer) > 0)
|
|
|
d0de29 |
- mpz_sub (result->value.integer, x->value.integer, y->value.integer);
|
|
|
d0de29 |
- else
|
|
|
d0de29 |
- mpz_set_ui (result->value.integer, 0);
|
|
|
d0de29 |
-
|
|
|
d0de29 |
- break;
|
|
|
d0de29 |
-
|
|
|
d0de29 |
- case BT_REAL:
|
|
|
d0de29 |
- if (mpfr_cmp (x->value.real, y->value.real) > 0)
|
|
|
d0de29 |
- mpfr_sub (result->value.real, x->value.real, y->value.real,
|
|
|
d0de29 |
- GFC_RND_MODE);
|
|
|
d0de29 |
- else
|
|
|
d0de29 |
- mpfr_set_ui (result->value.real, 0, GFC_RND_MODE);
|
|
|
d0de29 |
+ gfc_internal_error ("gfc_simplify_dim(): Bad arguments");
|
|
|
d0de29 |
+ return NULL;
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
|
|
|
d0de29 |
- break;
|
|
|
d0de29 |
+ kind = x->ts.kind > y->ts.kind ? x->ts.kind : y->ts.kind;
|
|
|
d0de29 |
|
|
|
d0de29 |
- default:
|
|
|
d0de29 |
- gfc_internal_error ("gfc_simplify_dim(): Bad type");
|
|
|
d0de29 |
+ if (simplify_int_real_promotion2 (x, y, &xr, &yr))
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ result = gfc_get_constant_expr (BT_REAL, kind, &x->where);
|
|
|
d0de29 |
+ if (mpfr_cmp (xr, yr) > 0)
|
|
|
d0de29 |
+ mpfr_sub (result->value.real, xr, yr, GFC_RND_MODE);
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ mpfr_set_ui (result->value.real, 0, GFC_RND_MODE);
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ result = gfc_get_constant_expr (BT_INTEGER, kind, &x->where);
|
|
|
d0de29 |
+ if (mpz_cmp (x->value.integer, y->value.integer) > 0)
|
|
|
d0de29 |
+ mpz_sub (result->value.integer, x->value.integer, y->value.integer);
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ mpz_set_ui (result->value.integer, 0);
|
|
|
d0de29 |
}
|
|
|
d0de29 |
|
|
|
d0de29 |
return range_check (result, "DIM");
|
|
|
d0de29 |
@@ -4886,13 +4926,87 @@ min_max_choose (gfc_expr *arg, gfc_expr *extremum, int sign, bool back_val)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
int ret;
|
|
|
d0de29 |
|
|
|
d0de29 |
+ mpfr_t *arp;
|
|
|
d0de29 |
+ mpfr_t *erp;
|
|
|
d0de29 |
+ mpfr_t ar;
|
|
|
d0de29 |
+ mpfr_t er;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ if (arg->ts.type != extremum->ts.type)
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ if (arg->ts.type == BT_REAL)
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ arp = &arg->value.real;
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ mpfr_init2 (ar, (arg->ts.kind * 8));
|
|
|
d0de29 |
+ mpfr_set_z (ar, arg->value.integer, GFC_RND_MODE);
|
|
|
d0de29 |
+ arp = &ar;
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ if (extremum->ts.type == BT_REAL)
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ erp = &extremum->value.real;
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ mpfr_init2 (er, (extremum->ts.kind * 8));
|
|
|
d0de29 |
+ mpfr_set_z (er, extremum->value.integer, GFC_RND_MODE);
|
|
|
d0de29 |
+ erp = &er;
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ if (mpfr_nan_p (*erp))
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ ret = 1;
|
|
|
d0de29 |
+ extremum->ts.type = arg->ts.type;
|
|
|
d0de29 |
+ extremum->ts.kind = arg->ts.kind;
|
|
|
d0de29 |
+ if (arg->ts.type == BT_INTEGER)
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ mpz_init2 (extremum->value.integer, (arg->ts.kind * 8));
|
|
|
d0de29 |
+ mpz_set (extremum->value.integer, arg->value.integer);
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ mpfr_init2 (extremum->value.real, (arg->ts.kind * 8));
|
|
|
d0de29 |
+ mpfr_set (extremum->value.real, *arp, GFC_RND_MODE);
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ else if (mpfr_nan_p (*arp))
|
|
|
d0de29 |
+ ret = -1;
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ ret = mpfr_cmp (*arp, *erp) * sign;
|
|
|
d0de29 |
+ if (ret > 0)
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ extremum->ts.type = arg->ts.type;
|
|
|
d0de29 |
+ extremum->ts.kind = arg->ts.kind;
|
|
|
d0de29 |
+ if (arg->ts.type == BT_INTEGER)
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ mpz_init2 (extremum->value.integer, (arg->ts.kind * 8));
|
|
|
d0de29 |
+ mpz_set (extremum->value.integer, arg->value.integer);
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ mpfr_init2 (extremum->value.real, (arg->ts.kind * 8));
|
|
|
d0de29 |
+ mpfr_set (extremum->value.real, *arp, GFC_RND_MODE);
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ return ret;
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+
|
|
|
d0de29 |
switch (arg->ts.type)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
case BT_INTEGER:
|
|
|
d0de29 |
ret = mpz_cmp (arg->value.integer,
|
|
|
d0de29 |
extremum->value.integer) * sign;
|
|
|
d0de29 |
if (ret > 0)
|
|
|
d0de29 |
- mpz_set (extremum->value.integer, arg->value.integer);
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ if (arg->ts.kind > extremum->ts.kind)
|
|
|
d0de29 |
+ extremum->ts.kind = arg->ts.kind;
|
|
|
d0de29 |
+ mpz_set (extremum->value.integer, arg->value.integer);
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
break;
|
|
|
d0de29 |
|
|
|
d0de29 |
case BT_REAL:
|
|
|
d0de29 |
@@ -5841,7 +5955,9 @@ gfc_simplify_mod (gfc_expr *a, gfc_expr *p)
|
|
|
d0de29 |
gfc_expr *result;
|
|
|
d0de29 |
int kind;
|
|
|
d0de29 |
|
|
|
d0de29 |
- /* First check p. */
|
|
|
d0de29 |
+ mpfr_t ar;
|
|
|
d0de29 |
+ mpfr_t pr;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
if (p->expr_type != EXPR_CONSTANT)
|
|
|
d0de29 |
return NULL;
|
|
|
d0de29 |
|
|
|
d0de29 |
@@ -5852,18 +5968,18 @@ gfc_simplify_mod (gfc_expr *a, gfc_expr *p)
|
|
|
d0de29 |
if (mpz_cmp_ui (p->value.integer, 0) == 0)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
gfc_error ("Argument %qs of MOD at %L shall not be zero",
|
|
|
d0de29 |
- "P", &p->where);
|
|
|
d0de29 |
+ "P", &p->where);
|
|
|
d0de29 |
return &gfc_bad_expr;
|
|
|
d0de29 |
}
|
|
|
d0de29 |
- break;
|
|
|
d0de29 |
+ break;
|
|
|
d0de29 |
case BT_REAL:
|
|
|
d0de29 |
if (mpfr_cmp_ui (p->value.real, 0) == 0)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
gfc_error ("Argument %qs of MOD at %L shall not be zero",
|
|
|
d0de29 |
- "P", &p->where);
|
|
|
d0de29 |
+ "P", &p->where);
|
|
|
d0de29 |
return &gfc_bad_expr;
|
|
|
d0de29 |
- }
|
|
|
d0de29 |
- break;
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ break;
|
|
|
d0de29 |
default:
|
|
|
d0de29 |
gfc_internal_error ("gfc_simplify_mod(): Bad arguments");
|
|
|
d0de29 |
}
|
|
|
d0de29 |
@@ -5871,16 +5987,24 @@ gfc_simplify_mod (gfc_expr *a, gfc_expr *p)
|
|
|
d0de29 |
if (a->expr_type != EXPR_CONSTANT)
|
|
|
d0de29 |
return NULL;
|
|
|
d0de29 |
|
|
|
d0de29 |
+ if (a->ts.type != BT_REAL && a->ts.type != BT_INTEGER)
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ gfc_internal_error ("gfc_simplify_mod(): Bad arguments");
|
|
|
d0de29 |
+ return NULL;
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+
|
|
|
d0de29 |
kind = a->ts.kind > p->ts.kind ? a->ts.kind : p->ts.kind;
|
|
|
d0de29 |
- result = gfc_get_constant_expr (a->ts.type, kind, &a->where);
|
|
|
d0de29 |
|
|
|
d0de29 |
- if (a->ts.type == BT_INTEGER)
|
|
|
d0de29 |
- mpz_tdiv_r (result->value.integer, a->value.integer, p->value.integer);
|
|
|
d0de29 |
- else
|
|
|
d0de29 |
+ if (simplify_int_real_promotion2 (a, p, &ar, &pr))
|
|
|
d0de29 |
{
|
|
|
d0de29 |
+ result = gfc_get_constant_expr (BT_REAL, kind, &a->where);
|
|
|
d0de29 |
gfc_set_model_kind (kind);
|
|
|
d0de29 |
- mpfr_fmod (result->value.real, a->value.real, p->value.real,
|
|
|
d0de29 |
- GFC_RND_MODE);
|
|
|
d0de29 |
+ mpfr_fmod (result->value.real, ar, pr, GFC_RND_MODE);
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ result = gfc_get_constant_expr (BT_INTEGER, kind, &a->where);
|
|
|
d0de29 |
+ mpz_tdiv_r (result->value.integer, a->value.integer, p->value.integer);
|
|
|
d0de29 |
}
|
|
|
d0de29 |
|
|
|
d0de29 |
return range_check (result, "MOD");
|
|
|
d0de29 |
@@ -5893,7 +6017,9 @@ gfc_simplify_modulo (gfc_expr *a, gfc_expr *p)
|
|
|
d0de29 |
gfc_expr *result;
|
|
|
d0de29 |
int kind;
|
|
|
d0de29 |
|
|
|
d0de29 |
- /* First check p. */
|
|
|
d0de29 |
+ mpfr_t ar;
|
|
|
d0de29 |
+ mpfr_t pr;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
if (p->expr_type != EXPR_CONSTANT)
|
|
|
d0de29 |
return NULL;
|
|
|
d0de29 |
|
|
|
d0de29 |
@@ -5904,44 +6030,52 @@ gfc_simplify_modulo (gfc_expr *a, gfc_expr *p)
|
|
|
d0de29 |
if (mpz_cmp_ui (p->value.integer, 0) == 0)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
gfc_error ("Argument %qs of MODULO at %L shall not be zero",
|
|
|
d0de29 |
- "P", &p->where);
|
|
|
d0de29 |
+ "P", &p->where);
|
|
|
d0de29 |
return &gfc_bad_expr;
|
|
|
d0de29 |
}
|
|
|
d0de29 |
- break;
|
|
|
d0de29 |
+ break;
|
|
|
d0de29 |
case BT_REAL:
|
|
|
d0de29 |
if (mpfr_cmp_ui (p->value.real, 0) == 0)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
gfc_error ("Argument %qs of MODULO at %L shall not be zero",
|
|
|
d0de29 |
- "P", &p->where);
|
|
|
d0de29 |
+ "P", &p->where);
|
|
|
d0de29 |
return &gfc_bad_expr;
|
|
|
d0de29 |
- }
|
|
|
d0de29 |
- break;
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ break;
|
|
|
d0de29 |
default:
|
|
|
d0de29 |
gfc_internal_error ("gfc_simplify_modulo(): Bad arguments");
|
|
|
d0de29 |
}
|
|
|
d0de29 |
|
|
|
d0de29 |
+ if (a->ts.type != BT_REAL && a->ts.type != BT_INTEGER)
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ gfc_internal_error ("gfc_simplify_modulo(): Bad arguments");
|
|
|
d0de29 |
+ return NULL;
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+
|
|
|
d0de29 |
if (a->expr_type != EXPR_CONSTANT)
|
|
|
d0de29 |
return NULL;
|
|
|
d0de29 |
|
|
|
d0de29 |
kind = a->ts.kind > p->ts.kind ? a->ts.kind : p->ts.kind;
|
|
|
d0de29 |
- result = gfc_get_constant_expr (a->ts.type, kind, &a->where);
|
|
|
d0de29 |
|
|
|
d0de29 |
- if (a->ts.type == BT_INTEGER)
|
|
|
d0de29 |
- mpz_fdiv_r (result->value.integer, a->value.integer, p->value.integer);
|
|
|
d0de29 |
- else
|
|
|
d0de29 |
+ if (simplify_int_real_promotion2 (a, p, &ar, &pr))
|
|
|
d0de29 |
{
|
|
|
d0de29 |
+ result = gfc_get_constant_expr (BT_REAL, kind, &a->where);
|
|
|
d0de29 |
gfc_set_model_kind (kind);
|
|
|
d0de29 |
- mpfr_fmod (result->value.real, a->value.real, p->value.real,
|
|
|
d0de29 |
- GFC_RND_MODE);
|
|
|
d0de29 |
+ mpfr_fmod (result->value.real, ar, pr, GFC_RND_MODE);
|
|
|
d0de29 |
if (mpfr_cmp_ui (result->value.real, 0) != 0)
|
|
|
d0de29 |
- {
|
|
|
d0de29 |
- if (mpfr_signbit (a->value.real) != mpfr_signbit (p->value.real))
|
|
|
d0de29 |
- mpfr_add (result->value.real, result->value.real, p->value.real,
|
|
|
d0de29 |
- GFC_RND_MODE);
|
|
|
d0de29 |
- }
|
|
|
d0de29 |
- else
|
|
|
d0de29 |
- mpfr_copysign (result->value.real, result->value.real,
|
|
|
d0de29 |
- p->value.real, GFC_RND_MODE);
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ if (mpfr_signbit (ar) != mpfr_signbit (pr))
|
|
|
d0de29 |
+ mpfr_add (result->value.real, result->value.real, pr,
|
|
|
d0de29 |
+ GFC_RND_MODE);
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ mpfr_copysign (result->value.real, result->value.real, pr,
|
|
|
d0de29 |
+ GFC_RND_MODE);
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+ else
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ result = gfc_get_constant_expr (BT_INTEGER, kind, &a->where);
|
|
|
d0de29 |
+ mpz_fdiv_r (result->value.integer, a->value.integer, p->value.integer);
|
|
|
d0de29 |
}
|
|
|
d0de29 |
|
|
|
d0de29 |
return range_check (result, "MODULO");
|
|
|
d0de29 |
@@ -7442,27 +7576,41 @@ gfc_expr *
|
|
|
d0de29 |
gfc_simplify_sign (gfc_expr *x, gfc_expr *y)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
gfc_expr *result;
|
|
|
d0de29 |
+ bool neg;
|
|
|
d0de29 |
|
|
|
d0de29 |
if (x->expr_type != EXPR_CONSTANT || y->expr_type != EXPR_CONSTANT)
|
|
|
d0de29 |
return NULL;
|
|
|
d0de29 |
|
|
|
d0de29 |
result = gfc_get_constant_expr (x->ts.type, x->ts.kind, &x->where);
|
|
|
d0de29 |
|
|
|
d0de29 |
+ switch (y->ts.type)
|
|
|
d0de29 |
+ {
|
|
|
d0de29 |
+ case BT_INTEGER:
|
|
|
d0de29 |
+ neg = (mpz_sgn (y->value.integer) < 0);
|
|
|
d0de29 |
+ break;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ case BT_REAL:
|
|
|
d0de29 |
+ neg = (mpfr_sgn (y->value.real) < 0);
|
|
|
d0de29 |
+ break;
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ default:
|
|
|
d0de29 |
+ gfc_internal_error ("Bad type in gfc_simplify_sign");
|
|
|
d0de29 |
+ }
|
|
|
d0de29 |
+
|
|
|
d0de29 |
switch (x->ts.type)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
case BT_INTEGER:
|
|
|
d0de29 |
mpz_abs (result->value.integer, x->value.integer);
|
|
|
d0de29 |
- if (mpz_sgn (y->value.integer) < 0)
|
|
|
d0de29 |
+ if (neg)
|
|
|
d0de29 |
mpz_neg (result->value.integer, result->value.integer);
|
|
|
d0de29 |
break;
|
|
|
d0de29 |
|
|
|
d0de29 |
case BT_REAL:
|
|
|
d0de29 |
- if (flag_sign_zero)
|
|
|
d0de29 |
+ if (flag_sign_zero && y->ts.type == BT_REAL)
|
|
|
d0de29 |
mpfr_copysign (result->value.real, x->value.real, y->value.real,
|
|
|
d0de29 |
- GFC_RND_MODE);
|
|
|
d0de29 |
+ GFC_RND_MODE);
|
|
|
d0de29 |
else
|
|
|
d0de29 |
- mpfr_setsign (result->value.real, x->value.real,
|
|
|
d0de29 |
- mpfr_sgn (y->value.real) < 0 ? 1 : 0, GFC_RND_MODE);
|
|
|
d0de29 |
+ mpfr_setsign (result->value.real, x->value.real, neg, GFC_RND_MODE);
|
|
|
d0de29 |
break;
|
|
|
d0de29 |
|
|
|
d0de29 |
default:
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_1.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_1.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..25763852139
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_1.f
|
|
|
d0de29 |
@@ -0,0 +1,18 @@
|
|
|
d0de29 |
+! { dg-do compile }
|
|
|
d0de29 |
+! { dg-options "-fdec" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Test promotion between integers and reals for mod and modulo where
|
|
|
d0de29 |
+! A is a constant array and P is zero.
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Compilation errors are expected
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
d0de29 |
+! and Jeff Law <law@redhat.com>
|
|
|
d0de29 |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ program promotion_int_real_array_const
|
|
|
d0de29 |
+ real a(2) = mod([12, 34], 0.0)*4 ! { dg-error "shall not be zero" }
|
|
|
d0de29 |
+ a = mod([12.0, 34.0], 0)*4 ! { dg-error "shall not be zero" }
|
|
|
d0de29 |
+ real b(2) = modulo([12, 34], 0.0)*4 ! { dg-error "shall not be zero" }
|
|
|
d0de29 |
+ b = modulo([12.0, 34.0], 0)*4 ! { dg-error "shall not be zero" }
|
|
|
d0de29 |
+ end program
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_2.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_2.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..b78a46054f4
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_2.f
|
|
|
d0de29 |
@@ -0,0 +1,18 @@
|
|
|
d0de29 |
+! { dg-do compile }
|
|
|
d0de29 |
+! { dg-options "-fdec-promotion" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Test promotion between integers and reals for mod and modulo where
|
|
|
d0de29 |
+! A is a constant array and P is zero.
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Compilation errors are expected
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
d0de29 |
+! and Jeff Law <law@redhat.com>
|
|
|
d0de29 |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ program promotion_int_real_array_const
|
|
|
d0de29 |
+ real a(2) = mod([12, 34], 0.0)*4 ! { dg-error "shall not be zero" }
|
|
|
d0de29 |
+ a = mod([12.0, 34.0], 0)*4 ! { dg-error "shall not be zero" }
|
|
|
d0de29 |
+ real b(2) = modulo([12, 34], 0.0)*4 ! { dg-error "shall not be zero" }
|
|
|
d0de29 |
+ b = modulo([12.0, 34.0], 0)*4 ! { dg-error "shall not be zero" }
|
|
|
d0de29 |
+ end program
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_3.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_3.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..318ab5db97e
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_array_const_promotion_3.f
|
|
|
d0de29 |
@@ -0,0 +1,18 @@
|
|
|
d0de29 |
+! { dg-do compile }
|
|
|
d0de29 |
+! { dg-options "-fdec -fno-dec-promotion" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Test promotion between integers and reals for mod and modulo where
|
|
|
d0de29 |
+! A is a constant array and P is zero.
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Compilation errors are expected
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
d0de29 |
+! and Jeff Law <law@redhat.com>
|
|
|
d0de29 |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ program promotion_int_real_array_const
|
|
|
d0de29 |
+ real a(2) = mod([12, 34], 0.0)*4 ! { dg-error "'a' and 'p' arguments of 'mod'" }
|
|
|
d0de29 |
+ a = mod([12.0, 34.0], 0)*4 ! { dg-error "'a' and 'p' arguments of 'mod'" }
|
|
|
d0de29 |
+ real b(2) = modulo([12, 34], 0.0)*4 ! { dg-error "'a' and 'p' arguments of 'modulo'" }
|
|
|
d0de29 |
+ b = modulo([12.0, 34.0], 0)*4 ! { dg-error "'a' and 'p' arguments of 'modulo'" }
|
|
|
d0de29 |
+ end program
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_1.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_1.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..27eb2582bb2
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_1.f
|
|
|
d0de29 |
@@ -0,0 +1,90 @@
|
|
|
d0de29 |
+! { dg-do run }
|
|
|
d0de29 |
+! { dg-options "-fdec -finit-real=snan" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Test promotion between integers and reals in intrinsic operations.
|
|
|
d0de29 |
+! These operations are: mod, modulo, dim, sign, min, max, minloc and
|
|
|
d0de29 |
+! maxloc.
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
d0de29 |
+! and Jeff Law <law@redhat.com>
|
|
|
d0de29 |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ PROGRAM promotion_int_real_const
|
|
|
d0de29 |
+ ! array_nan 4th position value is NAN
|
|
|
d0de29 |
+ REAL array_nan(4)
|
|
|
d0de29 |
+ DATA array_nan(1)/-4.0/
|
|
|
d0de29 |
+ DATA array_nan(2)/3.0/
|
|
|
d0de29 |
+ DATA array_nan(3)/-2/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER m_i/0/
|
|
|
d0de29 |
+ REAL m_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER md_i/0/
|
|
|
d0de29 |
+ REAL md_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER d_i/0/
|
|
|
d0de29 |
+ REAL d_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER s_i/0/
|
|
|
d0de29 |
+ REAL s_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mn_i/0/
|
|
|
d0de29 |
+ REAL mn_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mx_i/0/
|
|
|
d0de29 |
+ REAL mx_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ m_i = MOD(4, 3)
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 1
|
|
|
d0de29 |
+ m_r = MOD(4.0, 3.0)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 2
|
|
|
d0de29 |
+ m_r = MOD(4, 3.0)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 3
|
|
|
d0de29 |
+ m_r = MOD(4.0, 3)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 4
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ md_i = MODULO(4, 3)
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 5
|
|
|
d0de29 |
+ md_r = MODULO(4.0, 3.0)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 6
|
|
|
d0de29 |
+ md_r = MODULO(4, 3.0)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 7
|
|
|
d0de29 |
+ md_r = MODULO(4.0, 3)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 8
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ d_i = DIM(4, 3)
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 9
|
|
|
d0de29 |
+ d_r = DIM(4.0, 3.0)
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 10
|
|
|
d0de29 |
+ d_r = DIM(4.0, 3)
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 11
|
|
|
d0de29 |
+ d_r = DIM(3, 4.0)
|
|
|
d0de29 |
+ if (abs(d_r) > 1.0D-6) STOP 12
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ s_i = SIGN(-4, 3)
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 13
|
|
|
d0de29 |
+ s_r = SIGN(4.0, -3.0)
|
|
|
d0de29 |
+ if (abs(s_r - (-4.0)) > 1.0D-6) STOP 14
|
|
|
d0de29 |
+ s_r = SIGN(4.0, -3)
|
|
|
d0de29 |
+ if (abs(s_r - (-4.0)) > 1.0D-6) STOP 15
|
|
|
d0de29 |
+ s_r = SIGN(-4, 3.0)
|
|
|
d0de29 |
+ if (abs(s_r - 4.0) > 1.0D-6) STOP 16
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mx_i = MAX(-4, -3, 2, 1)
|
|
|
d0de29 |
+ if (mx_i .ne. 2) STOP 17
|
|
|
d0de29 |
+ mx_r = MAX(-4.0, -3.0, 2.0, 1.0)
|
|
|
d0de29 |
+ if (abs(mx_r - 2.0) > 1.0D-6) STOP 18
|
|
|
d0de29 |
+ mx_r = MAX(-4, -3.0, 2.0, 1)
|
|
|
d0de29 |
+ if (abs(mx_r - 2.0) > 1.0D-6) STOP 19
|
|
|
d0de29 |
+ mx_i = MAXLOC(array_nan, 1)
|
|
|
d0de29 |
+ if (mx_i .ne. 2) STOP 20
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mn_i = MIN(-4, -3, 2, 1)
|
|
|
d0de29 |
+ if (mn_i .ne. -4) STOP 21
|
|
|
d0de29 |
+ mn_r = MIN(-4.0, -3.0, 2.0, 1.0)
|
|
|
d0de29 |
+ if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 22
|
|
|
d0de29 |
+ mn_r = MIN(-4, -3.0, 2.0, 1)
|
|
|
d0de29 |
+ if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 23
|
|
|
d0de29 |
+ mn_i = MINLOC(array_nan, 1)
|
|
|
d0de29 |
+ if (mn_i .ne. 1) STOP 24
|
|
|
d0de29 |
+ END PROGRAM
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_2.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_2.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..bdd017b7280
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_2.f
|
|
|
d0de29 |
@@ -0,0 +1,90 @@
|
|
|
d0de29 |
+! { dg-do run }
|
|
|
d0de29 |
+! { dg-options "-fdec-promotion -finit-real=snan" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Test promotion between integers and reals in intrinsic operations.
|
|
|
d0de29 |
+! These operations are: mod, modulo, dim, sign, min, max, minloc and
|
|
|
d0de29 |
+! maxloc.
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
d0de29 |
+! and Jeff Law <law@redhat.com>
|
|
|
d0de29 |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ PROGRAM promotion_int_real_const
|
|
|
d0de29 |
+ ! array_nan 4th position value is NAN
|
|
|
d0de29 |
+ REAL array_nan(4)
|
|
|
d0de29 |
+ DATA array_nan(1)/-4.0/
|
|
|
d0de29 |
+ DATA array_nan(2)/3.0/
|
|
|
d0de29 |
+ DATA array_nan(3)/-2/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER m_i/0/
|
|
|
d0de29 |
+ REAL m_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER md_i/0/
|
|
|
d0de29 |
+ REAL md_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER d_i/0/
|
|
|
d0de29 |
+ REAL d_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER s_i/0/
|
|
|
d0de29 |
+ REAL s_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mn_i/0/
|
|
|
d0de29 |
+ REAL mn_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mx_i/0/
|
|
|
d0de29 |
+ REAL mx_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ m_i = MOD(4, 3)
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 1
|
|
|
d0de29 |
+ m_r = MOD(4.0, 3.0)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 2
|
|
|
d0de29 |
+ m_r = MOD(4, 3.0)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 3
|
|
|
d0de29 |
+ m_r = MOD(4.0, 3)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 4
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ md_i = MODULO(4, 3)
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 5
|
|
|
d0de29 |
+ md_r = MODULO(4.0, 3.0)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 6
|
|
|
d0de29 |
+ md_r = MODULO(4, 3.0)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 7
|
|
|
d0de29 |
+ md_r = MODULO(4.0, 3)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 8
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ d_i = DIM(4, 3)
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 9
|
|
|
d0de29 |
+ d_r = DIM(4.0, 3.0)
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 10
|
|
|
d0de29 |
+ d_r = DIM(4.0, 3)
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 11
|
|
|
d0de29 |
+ d_r = DIM(3, 4.0)
|
|
|
d0de29 |
+ if (abs(d_r) > 1.0D-6) STOP 12
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ s_i = SIGN(-4, 3)
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 13
|
|
|
d0de29 |
+ s_r = SIGN(4.0, -3.0)
|
|
|
d0de29 |
+ if (abs(s_r - (-4.0)) > 1.0D-6) STOP 14
|
|
|
d0de29 |
+ s_r = SIGN(4.0, -3)
|
|
|
d0de29 |
+ if (abs(s_r - (-4.0)) > 1.0D-6) STOP 15
|
|
|
d0de29 |
+ s_r = SIGN(-4, 3.0)
|
|
|
d0de29 |
+ if (abs(s_r - 4.0) > 1.0D-6) STOP 16
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mx_i = MAX(-4, -3, 2, 1)
|
|
|
d0de29 |
+ if (mx_i .ne. 2) STOP 17
|
|
|
d0de29 |
+ mx_r = MAX(-4.0, -3.0, 2.0, 1.0)
|
|
|
d0de29 |
+ if (abs(mx_r - 2.0) > 1.0D-6) STOP 18
|
|
|
d0de29 |
+ mx_r = MAX(-4, -3.0, 2.0, 1)
|
|
|
d0de29 |
+ if (abs(mx_r - 2.0) > 1.0D-6) STOP 19
|
|
|
d0de29 |
+ mx_i = MAXLOC(array_nan, 1)
|
|
|
d0de29 |
+ if (mx_i .ne. 2) STOP 20
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mn_i = MIN(-4, -3, 2, 1)
|
|
|
d0de29 |
+ if (mn_i .ne. -4) STOP 21
|
|
|
d0de29 |
+ mn_r = MIN(-4.0, -3.0, 2.0, 1.0)
|
|
|
d0de29 |
+ if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 22
|
|
|
d0de29 |
+ mn_r = MIN(-4, -3.0, 2.0, 1)
|
|
|
d0de29 |
+ if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 23
|
|
|
d0de29 |
+ mn_i = MINLOC(array_nan, 1)
|
|
|
d0de29 |
+ if (mn_i .ne. 1) STOP 24
|
|
|
d0de29 |
+ END PROGRAM
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_3.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_3.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..ce90a5667d6
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_const_promotion_3.f
|
|
|
d0de29 |
@@ -0,0 +1,92 @@
|
|
|
d0de29 |
+! { dg-do compile }
|
|
|
d0de29 |
+! { dg-options "-fdec -fno-dec-promotion -finit-real=snan" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Test that there is no promotion between integers and reals in
|
|
|
d0de29 |
+! intrinsic operations.
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! These operations are: mod, modulo, dim, sign, min, max, minloc and
|
|
|
d0de29 |
+! maxloc.
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
d0de29 |
+! and Jeff Law <law@redhat.com>
|
|
|
d0de29 |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ PROGRAM promotion_int_real_const
|
|
|
d0de29 |
+ ! array_nan 4th position value is NAN
|
|
|
d0de29 |
+ REAL array_nan(4)
|
|
|
d0de29 |
+ DATA array_nan(1)/-4.0/
|
|
|
d0de29 |
+ DATA array_nan(2)/3.0/
|
|
|
d0de29 |
+ DATA array_nan(3)/-2/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER m_i/0/
|
|
|
d0de29 |
+ REAL m_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER md_i/0/
|
|
|
d0de29 |
+ REAL md_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER d_i/0/
|
|
|
d0de29 |
+ REAL d_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER s_i/0/
|
|
|
d0de29 |
+ REAL s_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mn_i/0/
|
|
|
d0de29 |
+ REAL mn_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mx_i/0/
|
|
|
d0de29 |
+ REAL mx_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ m_i = MOD(4, 3)
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 1
|
|
|
d0de29 |
+ m_r = MOD(4.0, 3.0)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 2
|
|
|
d0de29 |
+ m_r = MOD(4, 3.0) ! { dg-error "'a' and 'p' arguments" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 3
|
|
|
d0de29 |
+ m_r = MOD(4.0, 3) ! { dg-error "'a' and 'p' arguments" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 4
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ md_i = MODULO(4, 3)
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 5
|
|
|
d0de29 |
+ md_r = MODULO(4.0, 3.0)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 6
|
|
|
d0de29 |
+ md_r = MODULO(4, 3.0) ! { dg-error "'a' and 'p' arguments" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 7
|
|
|
d0de29 |
+ md_r = MODULO(4.0, 3) ! { dg-error "'a' and 'p' arguments" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 8
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ d_i = DIM(4, 3)
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 9
|
|
|
d0de29 |
+ d_r = DIM(4.0, 3.0)
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 10
|
|
|
d0de29 |
+ d_r = DIM(4.0, 3) ! { dg-error "'x' and 'y' arguments" }
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 11
|
|
|
d0de29 |
+ d_r = DIM(3, 4.0) ! { dg-error "'x' and 'y' arguments" }
|
|
|
d0de29 |
+ if (abs(d_r) > 1.0D-6) STOP 12
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ s_i = SIGN(-4, 3)
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 13
|
|
|
d0de29 |
+ s_r = SIGN(4.0, -3.0)
|
|
|
d0de29 |
+ if (abs(s_r - (-4.0)) > 1.0D-6) STOP 14
|
|
|
d0de29 |
+ s_r = SIGN(4.0, -3) ! { dg-error "'b' argument" }
|
|
|
d0de29 |
+ if (abs(s_r - (-4.0)) > 1.0D-6) STOP 15
|
|
|
d0de29 |
+ s_r = SIGN(-4, 3.0) ! { dg-error "'b' argument" }
|
|
|
d0de29 |
+ if (abs(s_r - 4.0) > 1.0D-6) STOP 16
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mx_i = MAX(-4, -3, 2, 1)
|
|
|
d0de29 |
+ if (mx_i .ne. 2) STOP 17
|
|
|
d0de29 |
+ mx_r = MAX(-4.0, -3.0, 2.0, 1.0)
|
|
|
d0de29 |
+ if (abs(mx_r - 2.0) > 1.0D-6) STOP 18
|
|
|
d0de29 |
+ mx_r = MAX(-4, -3.0, 2.0, 1) ! { dg-error "'a2' argument" }
|
|
|
d0de29 |
+ if (abs(mx_r - 2.0) > 1.0D-6) STOP 19
|
|
|
d0de29 |
+ mx_i = MAXLOC(array_nan, 1)
|
|
|
d0de29 |
+ if (mx_i .ne. 2) STOP 20
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mn_i = MIN(-4, -3, 2, 1)
|
|
|
d0de29 |
+ if (mn_i .ne. -4) STOP 21
|
|
|
d0de29 |
+ mn_r = MIN(-4.0, -3.0, 2.0, 1.0)
|
|
|
d0de29 |
+ if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 22
|
|
|
d0de29 |
+ mn_r = MIN(-4, -3.0, 2.0, 1) ! { dg-error "'a2' argument" }
|
|
|
d0de29 |
+ if (abs(mn_r - (-4.0)) > 1.0D-6) STOP 23
|
|
|
d0de29 |
+ mn_i = MINLOC(array_nan, 1)
|
|
|
d0de29 |
+ if (mn_i .ne. 1) STOP 24
|
|
|
d0de29 |
+ END PROGRAM
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_1.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_1.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..5c2cd931a4b
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_1.f
|
|
|
d0de29 |
@@ -0,0 +1,130 @@
|
|
|
d0de29 |
+! { dg-do run }
|
|
|
d0de29 |
+! { dg-options "-fdec" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Test promotion between integers and reals in intrinsic operations.
|
|
|
d0de29 |
+! These operations are: mod, modulo, dim, sign, min, max, minloc and
|
|
|
d0de29 |
+! maxloc.
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
d0de29 |
+! and Jeff Law <law@redhat.com>
|
|
|
d0de29 |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ PROGRAM promotion_int_real
|
|
|
d0de29 |
+ REAL l/0.0/
|
|
|
d0de29 |
+ INTEGER a_i/4/
|
|
|
d0de29 |
+ INTEGER*4 a2_i/4/
|
|
|
d0de29 |
+ INTEGER b_i/3/
|
|
|
d0de29 |
+ INTEGER*8 b2_i/3/
|
|
|
d0de29 |
+ INTEGER x_i/2/
|
|
|
d0de29 |
+ INTEGER y_i/1/
|
|
|
d0de29 |
+ REAL a_r/4.0/
|
|
|
d0de29 |
+ REAL*4 a2_r/4.0/
|
|
|
d0de29 |
+ REAL b_r/3.0/
|
|
|
d0de29 |
+ REAL*8 b2_r/3.0/
|
|
|
d0de29 |
+ REAL x_r/2.0/
|
|
|
d0de29 |
+ REAL y_r/1.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ REAL array_nan(4)
|
|
|
d0de29 |
+ DATA array_nan(1)/-4.0/
|
|
|
d0de29 |
+ DATA array_nan(2)/3.0/
|
|
|
d0de29 |
+ DATA array_nan(3)/-2/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER m_i/0/
|
|
|
d0de29 |
+ REAL m_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER md_i/0/
|
|
|
d0de29 |
+ REAL md_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER d_i/0/
|
|
|
d0de29 |
+ REAL d_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER s_i/0/
|
|
|
d0de29 |
+ REAL s_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mn_i/0/
|
|
|
d0de29 |
+ REAL mn_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mx_i/0/
|
|
|
d0de29 |
+ REAL mx_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ ! array_nan 4th position value is NAN
|
|
|
d0de29 |
+ array_nan(4) = 0/l
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ m_i = MOD(a_i, b_i)
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 1
|
|
|
d0de29 |
+ m_i = MOD(a2_i, b2_i)
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 2
|
|
|
d0de29 |
+ m_r = MOD(a_r, b_r)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 3
|
|
|
d0de29 |
+ m_r = MOD(a2_r, b2_r)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 4
|
|
|
d0de29 |
+ m_r = MOD(a_i, b_r)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 5
|
|
|
d0de29 |
+ m_r = MOD(a_r, b_i)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 6
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ md_i = MODULO(a_i, b_i)
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 7
|
|
|
d0de29 |
+ md_i = MODULO(a2_i, b2_i)
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 8
|
|
|
d0de29 |
+ md_r = MODULO(a_r, b_r)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 9
|
|
|
d0de29 |
+ md_r = MODULO(a2_r, b2_r)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 10
|
|
|
d0de29 |
+ md_r = MODULO(a_i, b_r)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 11
|
|
|
d0de29 |
+ md_r = MODULO(a_r, b_i)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 12
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ d_i = DIM(a_i, b_i)
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 13
|
|
|
d0de29 |
+ d_i = DIM(a2_i, b2_i)
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 14
|
|
|
d0de29 |
+ d_r = DIM(a_r, b_r)
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 15
|
|
|
d0de29 |
+ d_r = DIM(a2_r, b2_r)
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 16
|
|
|
d0de29 |
+ d_r = DIM(a_r, b_i)
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 17
|
|
|
d0de29 |
+ d_r = DIM(b_i, a_r)
|
|
|
d0de29 |
+ if (abs(d_r) > 1.0D-6) STOP 18
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ s_i = SIGN(-a_i, b_i)
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 19
|
|
|
d0de29 |
+ s_i = SIGN(-a2_i, b2_i)
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 20
|
|
|
d0de29 |
+ s_r = SIGN(a_r, -b_r)
|
|
|
d0de29 |
+ if (abs(s_r - (-a_r)) > 1.0D-6) STOP 21
|
|
|
d0de29 |
+ s_r = SIGN(a2_r, -b2_r)
|
|
|
d0de29 |
+ if (abs(s_r - (-a2_r)) > 1.0D-6) STOP 22
|
|
|
d0de29 |
+ s_r = SIGN(a_r, -b_i)
|
|
|
d0de29 |
+ if (abs(s_r - (-a_r)) > 1.0D-6) STOP 23
|
|
|
d0de29 |
+ s_r = SIGN(-a_i, b_r)
|
|
|
d0de29 |
+ if (abs(s_r - a_r) > 1.0D-6) STOP 24
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mx_i = MAX(-a_i, -b_i, x_i, y_i)
|
|
|
d0de29 |
+ if (mx_i .ne. x_i) STOP 25
|
|
|
d0de29 |
+ mx_i = MAX(-a2_i, -b2_i, x_i, y_i)
|
|
|
d0de29 |
+ if (mx_i .ne. x_i) STOP 26
|
|
|
d0de29 |
+ mx_r = MAX(-a_r, -b_r, x_r, y_r)
|
|
|
d0de29 |
+ if (abs(mx_r - x_r) > 1.0D-6) STOP 27
|
|
|
d0de29 |
+ mx_r = MAX(-a_r, -b_r, x_r, y_r)
|
|
|
d0de29 |
+ if (abs(mx_r - x_r) > 1.0D-6) STOP 28
|
|
|
d0de29 |
+ mx_r = MAX(-a_i, -b_r, x_r, y_i)
|
|
|
d0de29 |
+ if (abs(mx_r - x_r) > 1.0D-6) STOP 29
|
|
|
d0de29 |
+ mx_i = MAXLOC(array_nan, 1)
|
|
|
d0de29 |
+ if (mx_i .ne. 2) STOP 30
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mn_i = MIN(-a_i, -b_i, x_i, y_i)
|
|
|
d0de29 |
+ if (mn_i .ne. -a_i) STOP 31
|
|
|
d0de29 |
+ mn_i = MIN(-a2_i, -b2_i, x_i, y_i)
|
|
|
d0de29 |
+ if (mn_i .ne. -a2_i) STOP 32
|
|
|
d0de29 |
+ mn_r = MIN(-a_r, -b_r, x_r, y_r)
|
|
|
d0de29 |
+ if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 33
|
|
|
d0de29 |
+ mn_r = MIN(-a2_r, -b2_r, x_r, y_r)
|
|
|
d0de29 |
+ if (abs(mn_r - (-a2_r)) > 1.0D-6) STOP 34
|
|
|
d0de29 |
+ mn_r = MIN(-a_i, -b_r, x_r, y_i)
|
|
|
d0de29 |
+ if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 35
|
|
|
d0de29 |
+ mn_i = MINLOC(array_nan, 1)
|
|
|
d0de29 |
+ if (mn_i .ne. 1) STOP 36
|
|
|
d0de29 |
+ END PROGRAM
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_2.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_2.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..d64d468f7d1
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_2.f
|
|
|
d0de29 |
@@ -0,0 +1,130 @@
|
|
|
d0de29 |
+! { dg-do run }
|
|
|
d0de29 |
+! { dg-options "-fdec-promotion" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Test promotion between integers and reals in intrinsic operations.
|
|
|
d0de29 |
+! These operations are: mod, modulo, dim, sign, min, max, minloc and
|
|
|
d0de29 |
+! maxloc.
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
d0de29 |
+! and Jeff Law <law@redhat.com>
|
|
|
d0de29 |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ PROGRAM promotion_int_real
|
|
|
d0de29 |
+ REAL l/0.0/
|
|
|
d0de29 |
+ INTEGER a_i/4/
|
|
|
d0de29 |
+ INTEGER*4 a2_i/4/
|
|
|
d0de29 |
+ INTEGER b_i/3/
|
|
|
d0de29 |
+ INTEGER*8 b2_i/3/
|
|
|
d0de29 |
+ INTEGER x_i/2/
|
|
|
d0de29 |
+ INTEGER y_i/1/
|
|
|
d0de29 |
+ REAL a_r/4.0/
|
|
|
d0de29 |
+ REAL*4 a2_r/4.0/
|
|
|
d0de29 |
+ REAL b_r/3.0/
|
|
|
d0de29 |
+ REAL*8 b2_r/3.0/
|
|
|
d0de29 |
+ REAL x_r/2.0/
|
|
|
d0de29 |
+ REAL y_r/1.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ REAL array_nan(4)
|
|
|
d0de29 |
+ DATA array_nan(1)/-4.0/
|
|
|
d0de29 |
+ DATA array_nan(2)/3.0/
|
|
|
d0de29 |
+ DATA array_nan(3)/-2/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER m_i/0/
|
|
|
d0de29 |
+ REAL m_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER md_i/0/
|
|
|
d0de29 |
+ REAL md_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER d_i/0/
|
|
|
d0de29 |
+ REAL d_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER s_i/0/
|
|
|
d0de29 |
+ REAL s_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mn_i/0/
|
|
|
d0de29 |
+ REAL mn_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mx_i/0/
|
|
|
d0de29 |
+ REAL mx_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ ! array_nan 4th position value is NAN
|
|
|
d0de29 |
+ array_nan(4) = 0/l
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ m_i = MOD(a_i, b_i)
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 1
|
|
|
d0de29 |
+ m_i = MOD(a2_i, b2_i)
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 2
|
|
|
d0de29 |
+ m_r = MOD(a_r, b_r)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 3
|
|
|
d0de29 |
+ m_r = MOD(a2_r, b2_r)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 4
|
|
|
d0de29 |
+ m_r = MOD(a_i, b_r)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 5
|
|
|
d0de29 |
+ m_r = MOD(a_r, b_i)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 6
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ md_i = MODULO(a_i, b_i)
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 7
|
|
|
d0de29 |
+ md_i = MODULO(a2_i, b2_i)
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 8
|
|
|
d0de29 |
+ md_r = MODULO(a_r, b_r)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 9
|
|
|
d0de29 |
+ md_r = MODULO(a2_r, b2_r)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 10
|
|
|
d0de29 |
+ md_r = MODULO(a_i, b_r)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 11
|
|
|
d0de29 |
+ md_r = MODULO(a_r, b_i)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 12
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ d_i = DIM(a_i, b_i)
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 13
|
|
|
d0de29 |
+ d_i = DIM(a2_i, b2_i)
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 14
|
|
|
d0de29 |
+ d_r = DIM(a_r, b_r)
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 15
|
|
|
d0de29 |
+ d_r = DIM(a2_r, b2_r)
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 16
|
|
|
d0de29 |
+ d_r = DIM(a_r, b_i)
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 17
|
|
|
d0de29 |
+ d_r = DIM(b_i, a_r)
|
|
|
d0de29 |
+ if (abs(d_r) > 1.0D-6) STOP 18
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ s_i = SIGN(-a_i, b_i)
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 19
|
|
|
d0de29 |
+ s_i = SIGN(-a2_i, b2_i)
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 20
|
|
|
d0de29 |
+ s_r = SIGN(a_r, -b_r)
|
|
|
d0de29 |
+ if (abs(s_r - (-a_r)) > 1.0D-6) STOP 21
|
|
|
d0de29 |
+ s_r = SIGN(a2_r, -b2_r)
|
|
|
d0de29 |
+ if (abs(s_r - (-a2_r)) > 1.0D-6) STOP 22
|
|
|
d0de29 |
+ s_r = SIGN(a_r, -b_i)
|
|
|
d0de29 |
+ if (abs(s_r - (-a_r)) > 1.0D-6) STOP 23
|
|
|
d0de29 |
+ s_r = SIGN(-a_i, b_r)
|
|
|
d0de29 |
+ if (abs(s_r - a_r) > 1.0D-6) STOP 24
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mx_i = MAX(-a_i, -b_i, x_i, y_i)
|
|
|
d0de29 |
+ if (mx_i .ne. x_i) STOP 25
|
|
|
d0de29 |
+ mx_i = MAX(-a2_i, -b2_i, x_i, y_i)
|
|
|
d0de29 |
+ if (mx_i .ne. x_i) STOP 26
|
|
|
d0de29 |
+ mx_r = MAX(-a_r, -b_r, x_r, y_r)
|
|
|
d0de29 |
+ if (abs(mx_r - x_r) > 1.0D-6) STOP 27
|
|
|
d0de29 |
+ mx_r = MAX(-a_r, -b_r, x_r, y_r)
|
|
|
d0de29 |
+ if (abs(mx_r - x_r) > 1.0D-6) STOP 28
|
|
|
d0de29 |
+ mx_r = MAX(-a_i, -b_r, x_r, y_i)
|
|
|
d0de29 |
+ if (abs(mx_r - x_r) > 1.0D-6) STOP 29
|
|
|
d0de29 |
+ mx_i = MAXLOC(array_nan, 1)
|
|
|
d0de29 |
+ if (mx_i .ne. 2) STOP 30
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mn_i = MIN(-a_i, -b_i, x_i, y_i)
|
|
|
d0de29 |
+ if (mn_i .ne. -a_i) STOP 31
|
|
|
d0de29 |
+ mn_i = MIN(-a2_i, -b2_i, x_i, y_i)
|
|
|
d0de29 |
+ if (mn_i .ne. -a2_i) STOP 32
|
|
|
d0de29 |
+ mn_r = MIN(-a_r, -b_r, x_r, y_r)
|
|
|
d0de29 |
+ if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 33
|
|
|
d0de29 |
+ mn_r = MIN(-a2_r, -b2_r, x_r, y_r)
|
|
|
d0de29 |
+ if (abs(mn_r - (-a2_r)) > 1.0D-6) STOP 34
|
|
|
d0de29 |
+ mn_r = MIN(-a_i, -b_r, x_r, y_i)
|
|
|
d0de29 |
+ if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 35
|
|
|
d0de29 |
+ mn_i = MINLOC(array_nan, 1)
|
|
|
d0de29 |
+ if (mn_i .ne. 1) STOP 36
|
|
|
d0de29 |
+ END PROGRAM
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_3.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_3.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..0708b666633
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_3.f
|
|
|
d0de29 |
@@ -0,0 +1,130 @@
|
|
|
d0de29 |
+! { dg-do compile }
|
|
|
d0de29 |
+! { dg-options "-fdec -fno-dec-promotion" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Test promotion between integers and reals in intrinsic operations.
|
|
|
d0de29 |
+! These operations are: mod, modulo, dim, sign, min, max, minloc and
|
|
|
d0de29 |
+! maxloc.
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
d0de29 |
+! and Jeff Law <law@redhat.com>
|
|
|
d0de29 |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ PROGRAM promotion_int_real
|
|
|
d0de29 |
+ REAL l/0.0/
|
|
|
d0de29 |
+ INTEGER a_i/4/
|
|
|
d0de29 |
+ INTEGER*4 a2_i/4/
|
|
|
d0de29 |
+ INTEGER b_i/3/
|
|
|
d0de29 |
+ INTEGER*8 b2_i/3/
|
|
|
d0de29 |
+ INTEGER x_i/2/
|
|
|
d0de29 |
+ INTEGER y_i/1/
|
|
|
d0de29 |
+ REAL a_r/4.0/
|
|
|
d0de29 |
+ REAL*4 a2_r/4.0/
|
|
|
d0de29 |
+ REAL b_r/3.0/
|
|
|
d0de29 |
+ REAL*8 b2_r/3.0/
|
|
|
d0de29 |
+ REAL x_r/2.0/
|
|
|
d0de29 |
+ REAL y_r/1.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ REAL array_nan(4)
|
|
|
d0de29 |
+ DATA array_nan(1)/-4.0/
|
|
|
d0de29 |
+ DATA array_nan(2)/3.0/
|
|
|
d0de29 |
+ DATA array_nan(3)/-2/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER m_i/0/
|
|
|
d0de29 |
+ REAL m_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER md_i/0/
|
|
|
d0de29 |
+ REAL md_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER d_i/0/
|
|
|
d0de29 |
+ REAL d_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER s_i/0/
|
|
|
d0de29 |
+ REAL s_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mn_i/0/
|
|
|
d0de29 |
+ REAL mn_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mx_i/0/
|
|
|
d0de29 |
+ REAL mx_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ ! array_nan 4th position value is NAN
|
|
|
d0de29 |
+ array_nan(4) = 0/l
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ m_i = MOD(a_i, b_i)
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 1
|
|
|
d0de29 |
+ m_i = MOD(a2_i, b2_i)
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 2
|
|
|
d0de29 |
+ m_r = MOD(a_r, b_r)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 3
|
|
|
d0de29 |
+ m_r = MOD(a2_r, b2_r)
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 4
|
|
|
d0de29 |
+ m_r = MOD(a_i, b_r) ! { dg-error "'a' and 'p' arguments" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 5
|
|
|
d0de29 |
+ m_r = MOD(a_r, b_i) ! { dg-error "'a' and 'p' arguments" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 6
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ md_i = MODULO(a_i, b_i)
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 7
|
|
|
d0de29 |
+ md_i = MODULO(a2_i, b2_i)
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 8
|
|
|
d0de29 |
+ md_r = MODULO(a_r, b_r)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 9
|
|
|
d0de29 |
+ md_r = MODULO(a2_r, b2_r)
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 10
|
|
|
d0de29 |
+ md_r = MODULO(a_i, b_r) ! { dg-error "'a' and 'p' arguments" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 11
|
|
|
d0de29 |
+ md_r = MODULO(a_r, b_i) ! { dg-error "'a' and 'p' arguments" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 12
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ d_i = DIM(a_i, b_i)
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 13
|
|
|
d0de29 |
+ d_i = DIM(a2_i, b2_i)
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 14
|
|
|
d0de29 |
+ d_r = DIM(a_r, b_r)
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 15
|
|
|
d0de29 |
+ d_r = DIM(a2_r, b2_r)
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 16
|
|
|
d0de29 |
+ d_r = DIM(a_r, b_i) ! { dg-error "'x' and 'y' arguments" }
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 17
|
|
|
d0de29 |
+ d_r = DIM(b_i, a_r) ! { dg-error "'x' and 'y' arguments" }
|
|
|
d0de29 |
+ if (abs(d_r) > 1.0D-6) STOP 18
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ s_i = SIGN(-a_i, b_i)
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 19
|
|
|
d0de29 |
+ s_i = SIGN(-a2_i, b2_i) ! { dg-error "'b' argument" }
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 20
|
|
|
d0de29 |
+ s_r = SIGN(a_r, -b_r)
|
|
|
d0de29 |
+ if (abs(s_r - (-a_r)) > 1.0D-6) STOP 21
|
|
|
d0de29 |
+ s_r = SIGN(a2_r, -b2_r) ! { dg-error "'b' argument" }
|
|
|
d0de29 |
+ if (abs(s_r - (-a2_r)) > 1.0D-6) STOP 22
|
|
|
d0de29 |
+ s_r = SIGN(a_r, -b_i) ! { dg-error "'b' argument" }
|
|
|
d0de29 |
+ if (abs(s_r - (-a_r)) > 1.0D-6) STOP 23
|
|
|
d0de29 |
+ s_r = SIGN(-a_i, b_r) ! { dg-error "'b' argument" }
|
|
|
d0de29 |
+ if (abs(s_r - a_r) > 1.0D-6) STOP 24
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mx_i = MAX(-a_i, -b_i, x_i, y_i)
|
|
|
d0de29 |
+ if (mx_i .ne. x_i) STOP 25
|
|
|
d0de29 |
+ mx_i = MAX(-a2_i, -b2_i, x_i, y_i)
|
|
|
d0de29 |
+ if (mx_i .ne. x_i) STOP 26
|
|
|
d0de29 |
+ mx_r = MAX(-a_r, -b_r, x_r, y_r)
|
|
|
d0de29 |
+ if (abs(mx_r - x_r) > 1.0D-6) STOP 27
|
|
|
d0de29 |
+ mx_r = MAX(-a_r, -b_r, x_r, y_r)
|
|
|
d0de29 |
+ if (abs(mx_r - x_r) > 1.0D-6) STOP 28
|
|
|
d0de29 |
+ mx_r = MAX(-a_i, -b_r, x_r, y_i) ! { dg-error "'a2' argument" }
|
|
|
d0de29 |
+ if (abs(mx_r - x_r) > 1.0D-6) STOP 29
|
|
|
d0de29 |
+ mx_i = MAXLOC(array_nan, 1)
|
|
|
d0de29 |
+ if (mx_i .ne. 2) STOP 30
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mn_i = MIN(-a_i, -b_i, x_i, y_i)
|
|
|
d0de29 |
+ if (mn_i .ne. -a_i) STOP 31
|
|
|
d0de29 |
+ mn_i = MIN(-a2_i, -b2_i, x_i, y_i)
|
|
|
d0de29 |
+ if (mn_i .ne. -a2_i) STOP 32
|
|
|
d0de29 |
+ mn_r = MIN(-a_r, -b_r, x_r, y_r)
|
|
|
d0de29 |
+ if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 33
|
|
|
d0de29 |
+ mn_r = MIN(-a2_r, -b2_r, x_r, y_r)
|
|
|
d0de29 |
+ if (abs(mn_r - (-a2_r)) > 1.0D-6) STOP 34
|
|
|
d0de29 |
+ mn_r = MIN(-a_i, -b_r, x_r, y_i) ! { dg-error "'a2' argument" }
|
|
|
d0de29 |
+ if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 35
|
|
|
d0de29 |
+ mn_i = MINLOC(array_nan, 1)
|
|
|
d0de29 |
+ if (mn_i .ne. 1) STOP 36
|
|
|
d0de29 |
+ END PROGRAM
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_4.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_4.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..efa4f236410
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_4.f
|
|
|
d0de29 |
@@ -0,0 +1,118 @@
|
|
|
d0de29 |
+! { dg-do compile }
|
|
|
d0de29 |
+! { dg-options "-fdec" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Test promotion between integers and reals in intrinsic operations.
|
|
|
d0de29 |
+! These operations are: mod, modulo, dim, sign, min, max, minloc and
|
|
|
d0de29 |
+! maxloc.
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
d0de29 |
+! and Jeff Law <law@redhat.com>
|
|
|
d0de29 |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ PROGRAM promotion_int_real
|
|
|
d0de29 |
+ REAL l/0.0/
|
|
|
d0de29 |
+ LOGICAL a_l
|
|
|
d0de29 |
+ LOGICAL*4 a2_l
|
|
|
d0de29 |
+ LOGICAL b_l
|
|
|
d0de29 |
+ LOGICAL*8 b2_l
|
|
|
d0de29 |
+ LOGICAL x_l
|
|
|
d0de29 |
+ LOGICAL y_l
|
|
|
d0de29 |
+ CHARACTER a_c
|
|
|
d0de29 |
+ CHARACTER*4 a2_c
|
|
|
d0de29 |
+ CHARACTER b_c
|
|
|
d0de29 |
+ CHARACTER*8 b2_c
|
|
|
d0de29 |
+ CHARACTER x_c
|
|
|
d0de29 |
+ CHARACTER y_c
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER m_i/0/
|
|
|
d0de29 |
+ REAL m_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER md_i/0/
|
|
|
d0de29 |
+ REAL md_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER d_i/0/
|
|
|
d0de29 |
+ REAL d_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER s_i/0/
|
|
|
d0de29 |
+ REAL s_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mn_i/0/
|
|
|
d0de29 |
+ REAL mn_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mx_i/0/
|
|
|
d0de29 |
+ REAL mx_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ m_i = MOD(a_l, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 1
|
|
|
d0de29 |
+ m_i = MOD(a2_l, b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 2
|
|
|
d0de29 |
+ m_r = MOD(a_c, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 3
|
|
|
d0de29 |
+ m_r = MOD(a2_c, b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 4
|
|
|
d0de29 |
+ m_r = MOD(a_l, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 5
|
|
|
d0de29 |
+ m_r = MOD(a_c, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 6
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ md_i = MODULO(a_l, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 7
|
|
|
d0de29 |
+ md_i = MODULO(a2_l, b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 8
|
|
|
d0de29 |
+ md_r = MODULO(a_c, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 9
|
|
|
d0de29 |
+ md_r = MODULO(a2_c, b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 10
|
|
|
d0de29 |
+ md_r = MODULO(a_l, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 11
|
|
|
d0de29 |
+ md_r = MODULO(a_c, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 12
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ d_i = DIM(a_l, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 13
|
|
|
d0de29 |
+ d_i = DIM(a2_l, b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 14
|
|
|
d0de29 |
+ d_r = DIM(a_c, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 15
|
|
|
d0de29 |
+ d_r = DIM(a2_c, b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 16
|
|
|
d0de29 |
+ d_r = DIM(a_c, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 17
|
|
|
d0de29 |
+ d_r = DIM(b_l, a_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r) > 1.0D-6) STOP 18
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ s_i = SIGN(-a_l, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 19
|
|
|
d0de29 |
+ s_i = SIGN(-a2_l, b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 20
|
|
|
d0de29 |
+ s_r = SIGN(a_c, -b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - (-a_c)) > 1.0D-6) STOP 21 ! { dg-error "" }
|
|
|
d0de29 |
+ s_r = SIGN(a2_c, -b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - (-a2_c)) > 1.0D-6) STOP 22 ! { dg-error "" }
|
|
|
d0de29 |
+ s_r = SIGN(a_c, -b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - (-a_c)) > 1.0D-6) STOP 23 ! { dg-error "" }
|
|
|
d0de29 |
+ s_r = SIGN(-a_l, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - a_c) > 1.0D-6) STOP 24 ! { dg-error "" }
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mx_i = MAX(-a_l, -b_l, x_l, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mx_i .ne. x_l) STOP 25 ! { dg-error "" }
|
|
|
d0de29 |
+ mx_i = MAX(-a2_l, -b2_l, x_l, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mx_i .ne. x_l) STOP 26 ! { dg-error "" }
|
|
|
d0de29 |
+ mx_r = MAX(-a_c, -b_c, x_c, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mx_r - x_c) > 1.0D-6) STOP 27 ! { dg-error "" }
|
|
|
d0de29 |
+ mx_r = MAX(-a_c, -b_c, x_c, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mx_r - x_c) > 1.0D-6) STOP 28 ! { dg-error "" }
|
|
|
d0de29 |
+ mx_r = MAX(-a_l, -b_c, x_c, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mx_r - x_c) > 1.0D-6) STOP 29 ! { dg-error "" }
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mn_i = MIN(-a_l, -b_l, x_l, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mn_i .ne. -a_l) STOP 31 ! { dg-error "" }
|
|
|
d0de29 |
+ mn_i = MIN(-a2_l, -b2_l, x_l, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mn_i .ne. -a2_l) STOP 32 ! { dg-error "" }
|
|
|
d0de29 |
+ mn_r = MIN(-a_c, -b_c, x_c, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mn_r - (-a_c)) > 1.0D-6) STOP 33 ! { dg-error "" }
|
|
|
d0de29 |
+ mn_r = MIN(-a2_c, -b2_c, x_c, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mn_r - (-a2_c)) > 1.0D-6) STOP 34 ! { dg-error "" }
|
|
|
d0de29 |
+ mn_r = MIN(-a_l, -b_c, x_c, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mn_r - (-a_c)) > 1.0D-6) STOP 35 ! { dg-error "" }
|
|
|
d0de29 |
+ END PROGRAM
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_5.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_5.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..d023af5086d
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_5.f
|
|
|
d0de29 |
@@ -0,0 +1,118 @@
|
|
|
d0de29 |
+! { dg-do compile }
|
|
|
d0de29 |
+! { dg-options "-fdec-promotion" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Test promotion between integers and reals in intrinsic operations.
|
|
|
d0de29 |
+! These operations are: mod, modulo, dim, sign, min, max, minloc and
|
|
|
d0de29 |
+! maxloc.
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
d0de29 |
+! and Jeff Law <law@redhat.com>
|
|
|
d0de29 |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ PROGRAM promotion_int_real
|
|
|
d0de29 |
+ REAL l/0.0/
|
|
|
d0de29 |
+ LOGICAL a_l
|
|
|
d0de29 |
+ LOGICAL*4 a2_l
|
|
|
d0de29 |
+ LOGICAL b_l
|
|
|
d0de29 |
+ LOGICAL*8 b2_l
|
|
|
d0de29 |
+ LOGICAL x_l
|
|
|
d0de29 |
+ LOGICAL y_l
|
|
|
d0de29 |
+ CHARACTER a_c
|
|
|
d0de29 |
+ CHARACTER*4 a2_c
|
|
|
d0de29 |
+ CHARACTER b_c
|
|
|
d0de29 |
+ CHARACTER*8 b2_c
|
|
|
d0de29 |
+ CHARACTER x_c
|
|
|
d0de29 |
+ CHARACTER y_c
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER m_i/0/
|
|
|
d0de29 |
+ REAL m_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER md_i/0/
|
|
|
d0de29 |
+ REAL md_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER d_i/0/
|
|
|
d0de29 |
+ REAL d_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER s_i/0/
|
|
|
d0de29 |
+ REAL s_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mn_i/0/
|
|
|
d0de29 |
+ REAL mn_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mx_i/0/
|
|
|
d0de29 |
+ REAL mx_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ m_i = MOD(a_l, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 1
|
|
|
d0de29 |
+ m_i = MOD(a2_l, b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 2
|
|
|
d0de29 |
+ m_r = MOD(a_c, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 3
|
|
|
d0de29 |
+ m_r = MOD(a2_c, b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 4
|
|
|
d0de29 |
+ m_r = MOD(a_l, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 5
|
|
|
d0de29 |
+ m_r = MOD(a_c, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 6
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ md_i = MODULO(a_l, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 7
|
|
|
d0de29 |
+ md_i = MODULO(a2_l, b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 8
|
|
|
d0de29 |
+ md_r = MODULO(a_c, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 9
|
|
|
d0de29 |
+ md_r = MODULO(a2_c, b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 10
|
|
|
d0de29 |
+ md_r = MODULO(a_l, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 11
|
|
|
d0de29 |
+ md_r = MODULO(a_c, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 12
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ d_i = DIM(a_l, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 13
|
|
|
d0de29 |
+ d_i = DIM(a2_l, b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 14
|
|
|
d0de29 |
+ d_r = DIM(a_c, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 15
|
|
|
d0de29 |
+ d_r = DIM(a2_c, b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 16
|
|
|
d0de29 |
+ d_r = DIM(a_c, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 17
|
|
|
d0de29 |
+ d_r = DIM(b_l, a_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r) > 1.0D-6) STOP 18
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ s_i = SIGN(-a_l, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 19
|
|
|
d0de29 |
+ s_i = SIGN(-a2_l, b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 20
|
|
|
d0de29 |
+ s_r = SIGN(a_c, -b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - (-a_c)) > 1.0D-6) STOP 21 ! { dg-error "" }
|
|
|
d0de29 |
+ s_r = SIGN(a2_c, -b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - (-a2_c)) > 1.0D-6) STOP 22 ! { dg-error "" }
|
|
|
d0de29 |
+ s_r = SIGN(a_c, -b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - (-a_c)) > 1.0D-6) STOP 23 ! { dg-error "" }
|
|
|
d0de29 |
+ s_r = SIGN(-a_l, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - a_c) > 1.0D-6) STOP 24 ! { dg-error "" }
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mx_i = MAX(-a_l, -b_l, x_l, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mx_i .ne. x_l) STOP 25 ! { dg-error "" }
|
|
|
d0de29 |
+ mx_i = MAX(-a2_l, -b2_l, x_l, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mx_i .ne. x_l) STOP 26 ! { dg-error "" }
|
|
|
d0de29 |
+ mx_r = MAX(-a_c, -b_c, x_c, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mx_r - x_c) > 1.0D-6) STOP 27 ! { dg-error "" }
|
|
|
d0de29 |
+ mx_r = MAX(-a_c, -b_c, x_c, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mx_r - x_c) > 1.0D-6) STOP 28 ! { dg-error "" }
|
|
|
d0de29 |
+ mx_r = MAX(-a_l, -b_c, x_c, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mx_r - x_c) > 1.0D-6) STOP 29 ! { dg-error "" }
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mn_i = MIN(-a_l, -b_l, x_l, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mn_i .ne. -a_l) STOP 31 ! { dg-error "" }
|
|
|
d0de29 |
+ mn_i = MIN(-a2_l, -b2_l, x_l, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mn_i .ne. -a2_l) STOP 32 ! { dg-error "" }
|
|
|
d0de29 |
+ mn_r = MIN(-a_c, -b_c, x_c, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mn_r - (-a_c)) > 1.0D-6) STOP 33 ! { dg-error "" }
|
|
|
d0de29 |
+ mn_r = MIN(-a2_c, -b2_c, x_c, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mn_r - (-a2_c)) > 1.0D-6) STOP 34 ! { dg-error "" }
|
|
|
d0de29 |
+ mn_r = MIN(-a_l, -b_c, x_c, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mn_r - (-a_c)) > 1.0D-6) STOP 35 ! { dg-error "" }
|
|
|
d0de29 |
+ END PROGRAM
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_6.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_6.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..00f8fb88f1b
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_6.f
|
|
|
d0de29 |
@@ -0,0 +1,118 @@
|
|
|
d0de29 |
+! { dg-do compile }
|
|
|
d0de29 |
+! { dg-options "-fdec" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Test promotion between integers and reals in intrinsic operations.
|
|
|
d0de29 |
+! These operations are: mod, modulo, dim, sign, min, max, minloc and
|
|
|
d0de29 |
+! maxloc.
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
d0de29 |
+! and Jeff Law <law@redhat.com>
|
|
|
d0de29 |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ PROGRAM promotion_int_real
|
|
|
d0de29 |
+ REAL l/0.0/
|
|
|
d0de29 |
+ INTEGER a_i/4/
|
|
|
d0de29 |
+ INTEGER*4 a2_i/4/
|
|
|
d0de29 |
+ CHARACTER b_c
|
|
|
d0de29 |
+ CHARACTER*8 b2_c
|
|
|
d0de29 |
+ INTEGER x_i/2/
|
|
|
d0de29 |
+ CHARACTER y_c
|
|
|
d0de29 |
+ REAL a_r/4.0/
|
|
|
d0de29 |
+ REAL*4 a2_r/4.0/
|
|
|
d0de29 |
+ LOGICAL b_l
|
|
|
d0de29 |
+ LOGICAL*8 b2_l
|
|
|
d0de29 |
+ REAL x_r/2.0/
|
|
|
d0de29 |
+ LOGICAL y_l
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER m_i/0/
|
|
|
d0de29 |
+ REAL m_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER md_i/0/
|
|
|
d0de29 |
+ REAL md_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER d_i/0/
|
|
|
d0de29 |
+ REAL d_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER s_i/0/
|
|
|
d0de29 |
+ REAL s_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mn_i/0/
|
|
|
d0de29 |
+ REAL mn_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mx_i/0/
|
|
|
d0de29 |
+ REAL mx_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ m_i = MOD(a_i, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 1
|
|
|
d0de29 |
+ m_i = MOD(a2_i, b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 2
|
|
|
d0de29 |
+ m_r = MOD(a_r, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 3
|
|
|
d0de29 |
+ m_r = MOD(a2_r, b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 4
|
|
|
d0de29 |
+ m_r = MOD(a_i, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 5
|
|
|
d0de29 |
+ m_r = MOD(a_r, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 6
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ md_i = MODULO(a_i, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 7
|
|
|
d0de29 |
+ md_i = MODULO(a2_i, b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 8
|
|
|
d0de29 |
+ md_r = MODULO(a_r, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 9
|
|
|
d0de29 |
+ md_r = MODULO(a2_r, b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 10
|
|
|
d0de29 |
+ md_r = MODULO(a_i, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 11
|
|
|
d0de29 |
+ md_r = MODULO(a_r, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 12
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ d_i = DIM(a_i, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 13
|
|
|
d0de29 |
+ d_i = DIM(a2_i, b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 14
|
|
|
d0de29 |
+ d_r = DIM(a_r, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 15
|
|
|
d0de29 |
+ d_r = DIM(a2_r, b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 16
|
|
|
d0de29 |
+ d_r = DIM(a_r, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 17
|
|
|
d0de29 |
+ d_r = DIM(b_c, a_r) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r) > 1.0D-6) STOP 18
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ s_i = SIGN(-a_i, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 19
|
|
|
d0de29 |
+ s_i = SIGN(-a2_i, b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 20
|
|
|
d0de29 |
+ s_r = SIGN(a_r, -b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - (-a_r)) > 1.0D-6) STOP 21
|
|
|
d0de29 |
+ s_r = SIGN(a2_r, -b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - (-a2_r)) > 1.0D-6) STOP 22
|
|
|
d0de29 |
+ s_r = SIGN(a_r, -b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - (-a_r)) > 1.0D-6) STOP 23
|
|
|
d0de29 |
+ s_r = SIGN(-a_i, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - a_r) > 1.0D-6) STOP 24
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mx_i = MAX(-a_i, -b_c, x_i, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mx_i .ne. x_i) STOP 25
|
|
|
d0de29 |
+ mx_i = MAX(-a2_i, -b2_c, x_i, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mx_i .ne. x_i) STOP 26
|
|
|
d0de29 |
+ mx_r = MAX(-a_r, -b_l, x_r, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mx_r - x_r) > 1.0D-6) STOP 27
|
|
|
d0de29 |
+ mx_r = MAX(-a_r, -b_l, x_r, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mx_r - x_r) > 1.0D-6) STOP 28
|
|
|
d0de29 |
+ mx_r = MAX(-a_i, -b_l, x_r, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mx_r - x_r) > 1.0D-6) STOP 29
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mn_i = MIN(-a_i, -b_c, x_i, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mn_i .ne. -a_i) STOP 31
|
|
|
d0de29 |
+ mn_i = MIN(-a2_i, -b2_c, x_i, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mn_i .ne. -a2_i) STOP 32
|
|
|
d0de29 |
+ mn_r = MIN(-a_r, -b_l, x_r, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 33
|
|
|
d0de29 |
+ mn_r = MIN(-a2_r, -b2_l, x_r, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mn_r - (-a2_r)) > 1.0D-6) STOP 34
|
|
|
d0de29 |
+ mn_r = MIN(-a_i, -b_l, x_r, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 35
|
|
|
d0de29 |
+ END PROGRAM
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_7.f b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_7.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..1d4150d81c0
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_intrinsic_int_real_promotion_7.f
|
|
|
d0de29 |
@@ -0,0 +1,118 @@
|
|
|
d0de29 |
+! { dg-do compile }
|
|
|
d0de29 |
+! { dg-options "-fdec-promotion" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Test promotion between integers and reals in intrinsic operations.
|
|
|
d0de29 |
+! These operations are: mod, modulo, dim, sign, min, max, minloc and
|
|
|
d0de29 |
+! maxloc.
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
d0de29 |
+! and Jeff Law <law@redhat.com>
|
|
|
d0de29 |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ PROGRAM promotion_int_real
|
|
|
d0de29 |
+ REAL l/0.0/
|
|
|
d0de29 |
+ INTEGER a_i/4/
|
|
|
d0de29 |
+ INTEGER*4 a2_i/4/
|
|
|
d0de29 |
+ CHARACTER b_c
|
|
|
d0de29 |
+ CHARACTER*8 b2_c
|
|
|
d0de29 |
+ INTEGER x_i/2/
|
|
|
d0de29 |
+ CHARACTER y_c
|
|
|
d0de29 |
+ REAL a_r/4.0/
|
|
|
d0de29 |
+ REAL*4 a2_r/4.0/
|
|
|
d0de29 |
+ LOGICAL b_l
|
|
|
d0de29 |
+ LOGICAL*8 b2_l
|
|
|
d0de29 |
+ REAL x_r/2.0/
|
|
|
d0de29 |
+ LOGICAL y_l
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER m_i/0/
|
|
|
d0de29 |
+ REAL m_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER md_i/0/
|
|
|
d0de29 |
+ REAL md_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER d_i/0/
|
|
|
d0de29 |
+ REAL d_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER s_i/0/
|
|
|
d0de29 |
+ REAL s_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mn_i/0/
|
|
|
d0de29 |
+ REAL mn_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ INTEGER mx_i/0/
|
|
|
d0de29 |
+ REAL mx_r/0.0/
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ m_i = MOD(a_i, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 1
|
|
|
d0de29 |
+ m_i = MOD(a2_i, b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (m_i .ne. 1) STOP 2
|
|
|
d0de29 |
+ m_r = MOD(a_r, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 3
|
|
|
d0de29 |
+ m_r = MOD(a2_r, b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 4
|
|
|
d0de29 |
+ m_r = MOD(a_i, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 5
|
|
|
d0de29 |
+ m_r = MOD(a_r, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(m_r - 1.0) > 1.0D-6) STOP 6
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ md_i = MODULO(a_i, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 7
|
|
|
d0de29 |
+ md_i = MODULO(a2_i, b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (md_i .ne. 1) STOP 8
|
|
|
d0de29 |
+ md_r = MODULO(a_r, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 9
|
|
|
d0de29 |
+ md_r = MODULO(a2_r, b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 10
|
|
|
d0de29 |
+ md_r = MODULO(a_i, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 11
|
|
|
d0de29 |
+ md_r = MODULO(a_r, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(md_r - 1.0) > 1.0D-6) STOP 12
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ d_i = DIM(a_i, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 13
|
|
|
d0de29 |
+ d_i = DIM(a2_i, b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (d_i .ne. 1) STOP 14
|
|
|
d0de29 |
+ d_r = DIM(a_r, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 15
|
|
|
d0de29 |
+ d_r = DIM(a2_r, b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 16
|
|
|
d0de29 |
+ d_r = DIM(a_r, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r - 1.0) > 1.0D-6) STOP 17
|
|
|
d0de29 |
+ d_r = DIM(b_c, a_r) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(d_r) > 1.0D-6) STOP 18
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ s_i = SIGN(-a_i, b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 19
|
|
|
d0de29 |
+ s_i = SIGN(-a2_i, b2_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (s_i .ne. 4) STOP 20
|
|
|
d0de29 |
+ s_r = SIGN(a_r, -b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - (-a_r)) > 1.0D-6) STOP 21
|
|
|
d0de29 |
+ s_r = SIGN(a2_r, -b2_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - (-a2_r)) > 1.0D-6) STOP 22
|
|
|
d0de29 |
+ s_r = SIGN(a_r, -b_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - (-a_r)) > 1.0D-6) STOP 23
|
|
|
d0de29 |
+ s_r = SIGN(-a_i, b_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(s_r - a_r) > 1.0D-6) STOP 24
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mx_i = MAX(-a_i, -b_c, x_i, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mx_i .ne. x_i) STOP 25
|
|
|
d0de29 |
+ mx_i = MAX(-a2_i, -b2_c, x_i, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mx_i .ne. x_i) STOP 26
|
|
|
d0de29 |
+ mx_r = MAX(-a_r, -b_l, x_r, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mx_r - x_r) > 1.0D-6) STOP 27
|
|
|
d0de29 |
+ mx_r = MAX(-a_r, -b_l, x_r, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mx_r - x_r) > 1.0D-6) STOP 28
|
|
|
d0de29 |
+ mx_r = MAX(-a_i, -b_l, x_r, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mx_r - x_r) > 1.0D-6) STOP 29
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ mn_i = MIN(-a_i, -b_c, x_i, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mn_i .ne. -a_i) STOP 31
|
|
|
d0de29 |
+ mn_i = MIN(-a2_i, -b2_c, x_i, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (mn_i .ne. -a2_i) STOP 32
|
|
|
d0de29 |
+ mn_r = MIN(-a_r, -b_l, x_r, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 33
|
|
|
d0de29 |
+ mn_r = MIN(-a2_r, -b2_l, x_r, y_l) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mn_r - (-a2_r)) > 1.0D-6) STOP 34
|
|
|
d0de29 |
+ mn_r = MIN(-a_i, -b_l, x_r, y_c) ! { dg-error "" }
|
|
|
d0de29 |
+ if (abs(mn_r - (-a_r)) > 1.0D-6) STOP 35
|
|
|
d0de29 |
+ END PROGRAM
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_kind_promotion-1.f b/gcc/testsuite/gfortran.dg/dec_kind_promotion-1.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..435bf98350c
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_kind_promotion-1.f
|
|
|
d0de29 |
@@ -0,0 +1,40 @@
|
|
|
d0de29 |
+!{ dg-do run }
|
|
|
d0de29 |
+!{ dg-options "-fdec" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! integer types of a smaller kind than expected should be
|
|
|
d0de29 |
+! accepted by type specific intrinsic functions
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ program test_small_type_promtion
|
|
|
d0de29 |
+ implicit none
|
|
|
d0de29 |
+ integer(1) :: a = 1
|
|
|
d0de29 |
+ integer :: i
|
|
|
d0de29 |
+ if (iiabs(-9_1).ne.9) stop 1
|
|
|
d0de29 |
+ if (iabs(-9_1).ne.9) stop 2
|
|
|
d0de29 |
+ if (iabs(-9_2).ne.9) stop 3
|
|
|
d0de29 |
+ if (jiabs(-9_1).ne.9) stop 4
|
|
|
d0de29 |
+ if (jiabs(-9_2).ne.9) stop 5
|
|
|
d0de29 |
+ if (iishft(1_1, 2).ne.4) stop 6
|
|
|
d0de29 |
+ if (jishft(1_1, 2).ne.4) stop 7
|
|
|
d0de29 |
+ if (jishft(1_2, 2).ne.4) stop 8
|
|
|
d0de29 |
+ if (kishft(1_1, 2).ne.4) stop 9
|
|
|
d0de29 |
+ if (kishft(1_2, 2).ne.4) stop 10
|
|
|
d0de29 |
+ if (kishft(1_4, 2).ne.4) stop 11
|
|
|
d0de29 |
+ if (imod(17_1, 3).ne.2) stop 12
|
|
|
d0de29 |
+ if (jmod(17_1, 3).ne.2) stop 13
|
|
|
d0de29 |
+ if (jmod(17_2, 3).ne.2) stop 14
|
|
|
d0de29 |
+ if (kmod(17_1, 3).ne.2) stop 15
|
|
|
d0de29 |
+ if (kmod(17_2, 3).ne.2) stop 16
|
|
|
d0de29 |
+ if (kmod(17_4, 3).ne.2) stop 17
|
|
|
d0de29 |
+ if (inot(5_1).ne.-6) stop 18
|
|
|
d0de29 |
+ if (jnot(5_1).ne.-6) stop 19
|
|
|
d0de29 |
+ if (jnot(5_2).ne.-6) stop 20
|
|
|
d0de29 |
+ if (knot(5_1).ne.-6) stop 21
|
|
|
d0de29 |
+ if (knot(5_2).ne.-6) stop 22
|
|
|
d0de29 |
+ if (knot(5_4).ne.-6) stop 23
|
|
|
d0de29 |
+ if (isign(-77_1, 1).ne.77) stop 24
|
|
|
d0de29 |
+ if (isign(-77_1, -1).ne.-77) stop 25
|
|
|
d0de29 |
+ if (isign(-77_2, 1).ne.77) stop 26
|
|
|
d0de29 |
+ if (isign(-77_2, -1).ne.-77) stop 27
|
|
|
d0de29 |
+ end program
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_kind_promotion-2.f b/gcc/testsuite/gfortran.dg/dec_kind_promotion-2.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..7b1697ca665
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_kind_promotion-2.f
|
|
|
d0de29 |
@@ -0,0 +1,40 @@
|
|
|
d0de29 |
+!{ dg-do run }
|
|
|
d0de29 |
+!{ dg-options "-fdec-intrinsic-ints -fdec-promotion" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! integer types of a smaller kind than expected should be
|
|
|
d0de29 |
+! accepted by type specific intrinsic functions
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ program test_small_type_promtion
|
|
|
d0de29 |
+ implicit none
|
|
|
d0de29 |
+ integer(1) :: a = 1
|
|
|
d0de29 |
+ integer :: i
|
|
|
d0de29 |
+ if (iiabs(-9_1).ne.9) stop 1
|
|
|
d0de29 |
+ if (iabs(-9_1).ne.9) stop 2
|
|
|
d0de29 |
+ if (iabs(-9_2).ne.9) stop 3
|
|
|
d0de29 |
+ if (jiabs(-9_1).ne.9) stop 4
|
|
|
d0de29 |
+ if (jiabs(-9_2).ne.9) stop 5
|
|
|
d0de29 |
+ if (iishft(1_1, 2).ne.4) stop 6
|
|
|
d0de29 |
+ if (jishft(1_1, 2).ne.4) stop 7
|
|
|
d0de29 |
+ if (jishft(1_2, 2).ne.4) stop 8
|
|
|
d0de29 |
+ if (kishft(1_1, 2).ne.4) stop 9
|
|
|
d0de29 |
+ if (kishft(1_2, 2).ne.4) stop 10
|
|
|
d0de29 |
+ if (kishft(1_4, 2).ne.4) stop 11
|
|
|
d0de29 |
+ if (imod(17_1, 3).ne.2) stop 12
|
|
|
d0de29 |
+ if (jmod(17_1, 3).ne.2) stop 13
|
|
|
d0de29 |
+ if (jmod(17_2, 3).ne.2) stop 14
|
|
|
d0de29 |
+ if (kmod(17_1, 3).ne.2) stop 15
|
|
|
d0de29 |
+ if (kmod(17_2, 3).ne.2) stop 16
|
|
|
d0de29 |
+ if (kmod(17_4, 3).ne.2) stop 17
|
|
|
d0de29 |
+ if (inot(5_1).ne.-6) stop 18
|
|
|
d0de29 |
+ if (jnot(5_1).ne.-6) stop 19
|
|
|
d0de29 |
+ if (jnot(5_2).ne.-6) stop 20
|
|
|
d0de29 |
+ if (knot(5_1).ne.-6) stop 21
|
|
|
d0de29 |
+ if (knot(5_2).ne.-6) stop 22
|
|
|
d0de29 |
+ if (knot(5_4).ne.-6) stop 23
|
|
|
d0de29 |
+ if (isign(-77_1, 1).ne.77) stop 24
|
|
|
d0de29 |
+ if (isign(-77_1, -1).ne.-77) stop 25
|
|
|
d0de29 |
+ if (isign(-77_2, 1).ne.77) stop 26
|
|
|
d0de29 |
+ if (isign(-77_2, -1).ne.-77) stop 27
|
|
|
d0de29 |
+ end program
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_kind_promotion-3.f b/gcc/testsuite/gfortran.dg/dec_kind_promotion-3.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..b9d550a5a48
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_kind_promotion-3.f
|
|
|
d0de29 |
@@ -0,0 +1,40 @@
|
|
|
d0de29 |
+!{ dg-do compile }
|
|
|
d0de29 |
+!{ dg-options "-fdec -fno-dec-promotion" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! integer types of a smaller kind than expected should be
|
|
|
d0de29 |
+! accepted by type specific intrinsic functions
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Contributed by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ program test_small_type_promtion
|
|
|
d0de29 |
+ implicit none
|
|
|
d0de29 |
+ integer(1) :: a = 1
|
|
|
d0de29 |
+ integer :: i
|
|
|
d0de29 |
+ if (iiabs(-9_1).ne.9) stop 1
|
|
|
d0de29 |
+ if (iabs(-9_1).ne.9) stop 2 ! { dg-error "Type of argument" }
|
|
|
d0de29 |
+ if (iabs(-9_2).ne.9) stop 3 ! { dg-error "Type of argument" }
|
|
|
d0de29 |
+ if (jiabs(-9_1).ne.9) stop 4
|
|
|
d0de29 |
+ if (jiabs(-9_2).ne.9) stop 5
|
|
|
d0de29 |
+ if (iishft(1_1, 2).ne.4) stop 6
|
|
|
d0de29 |
+ if (jishft(1_1, 2).ne.4) stop 7
|
|
|
d0de29 |
+ if (jishft(1_2, 2).ne.4) stop 8
|
|
|
d0de29 |
+ if (kishft(1_1, 2).ne.4) stop 9
|
|
|
d0de29 |
+ if (kishft(1_2, 2).ne.4) stop 10
|
|
|
d0de29 |
+ if (kishft(1_4, 2).ne.4) stop 11
|
|
|
d0de29 |
+ if (imod(17_1, 3).ne.2) stop 12
|
|
|
d0de29 |
+ if (jmod(17_1, 3).ne.2) stop 13
|
|
|
d0de29 |
+ if (jmod(17_2, 3).ne.2) stop 14
|
|
|
d0de29 |
+ if (kmod(17_1, 3).ne.2) stop 15
|
|
|
d0de29 |
+ if (kmod(17_2, 3).ne.2) stop 16
|
|
|
d0de29 |
+ if (kmod(17_4, 3).ne.2) stop 17
|
|
|
d0de29 |
+ if (inot(5_1).ne.-6) stop 18
|
|
|
d0de29 |
+ if (jnot(5_1).ne.-6) stop 19
|
|
|
d0de29 |
+ if (jnot(5_2).ne.-6) stop 20
|
|
|
d0de29 |
+ if (knot(5_1).ne.-6) stop 21
|
|
|
d0de29 |
+ if (knot(5_2).ne.-6) stop 22
|
|
|
d0de29 |
+ if (knot(5_4).ne.-6) stop 23
|
|
|
d0de29 |
+ if (isign(-77_1, 1).ne.77) stop 24 ! { dg-error "Type of argument" }
|
|
|
d0de29 |
+ if (isign(-77_1, -1).ne.-77) stop 25 ! { dg-error "Type of argument" }
|
|
|
d0de29 |
+ if (isign(-77_2, 1).ne.77) stop 26 ! { dg-error "Type of argument" }
|
|
|
d0de29 |
+ if (isign(-77_2, -1).ne.-77) stop 27 ! { dg-error "Type of argument" }
|
|
|
d0de29 |
+ end program
|
|
|
d0de29 |
--
|
|
|
d0de29 |
2.11.0
|
|
|
d0de29 |
|