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