]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/85896 (ICE in gfc_convert_constant(): Unexpected type)
authorThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 30 Oct 2018 23:04:10 +0000 (23:04 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 30 Oct 2018 23:04:10 +0000 (23:04 +0000)
2018-10-30  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/85896
* simplify.c (simplify_min_max): Do not convert the type of the
return expression.

2018-10-30  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/85896
* gfortran.dg/min_max_type.f90: New test.

From-SVN: r265649

gcc/fortran/ChangeLog
gcc/fortran/simplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/min_max_type.f90 [new file with mode: 0644]

index b5675d11fa3b5db62ab56da5ff7639779080a7b3..1186a40e4b5a070a1c1eb4ab77c4b13c88535d17 100644 (file)
@@ -1,3 +1,9 @@
+2018-10-30  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/85896
+       * simplify.c (simplify_min_max): Do not convert the type of the
+       return expression.
+
 2017-10-28  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/54613
index 3939d26a9a709b9fe39184038a745b23645627b4..2c87ae95f9877ad53ac278055a6226ba2fcf7880 100644 (file)
@@ -4961,11 +4961,9 @@ static gfc_expr *
 simplify_min_max (gfc_expr *expr, int sign)
 {
   gfc_actual_arglist *arg, *last, *extremum;
-  gfc_intrinsic_sym * specific;
 
   last = NULL;
   extremum = NULL;
-  specific = expr->value.function.isym;
 
   arg = expr->value.function.actual;
 
@@ -4995,15 +4993,6 @@ simplify_min_max (gfc_expr *expr, int sign)
   if (expr->value.function.actual->next != NULL)
     return NULL;
 
-  /* Convert to the correct type and kind.  */
-  if (expr->ts.type != BT_UNKNOWN)
-    return gfc_convert_constant (expr->value.function.actual->expr,
-       expr->ts.type, expr->ts.kind);
-
-  if (specific->ts.type != BT_UNKNOWN)
-    return gfc_convert_constant (expr->value.function.actual->expr,
-       specific->ts.type, specific->ts.kind);
-
   return gfc_copy_expr (expr->value.function.actual->expr);
 }
 
index 3d96f1caaa006c4772309bcf2e40b25fcc5615d1..5b8090f008c193ff040ee79c3e167e86a8cedbb6 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-30  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/85896
+       * gfortran.dg/min_max_type.f90: New test.
+
 2018-10-30  Martin Sebor  <msebor@redhat.com>
 
        PR middle-end/87041
diff --git a/gcc/testsuite/gfortran.dg/min_max_type.f90 b/gcc/testsuite/gfortran.dg/min_max_type.f90
new file mode 100644 (file)
index 0000000..58137ad
--- /dev/null
@@ -0,0 +1,10 @@
+! { dg-do  run }
+! Make sure this is evaluated correctly even though max
+! has been declared integer.
+! Original test case by Gerhard Steinmetz.
+program main
+  integer :: max
+  character(len=1), parameter :: c = max('a','b')
+  character(len=1), parameter :: d = min('a','b')
+  if (c /= 'b' .or. d /= 'a') stop 1
+end program main