re PR fortran/68560 (The test gfortran.dg/shape_8.f90 now fails when compiled with...
authorThomas Koenig <tkoenig@gcc.gnu.org>
Wed, 7 Feb 2018 21:08:51 +0000 (21:08 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Wed, 7 Feb 2018 21:08:51 +0000 (21:08 +0000)
2018-02-07  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/68560
* trans-intrinsic.c (gfc_conv_intrinsic_shape): New function.
(gfc_conv_intrinsic_function): Call it.

2018-02-07  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/68560
* gfortran.dg/shape_9.f90: New test.

From-SVN: r257462

gcc/fortran/ChangeLog
gcc/fortran/trans-intrinsic.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/shape_9.f90 [new file with mode: 0644]

index 4b2343c9ed7bd4414c0cdc2adc923e83cce1284b..7dbb9c1984918b0bad37bff124be536e8f39ce2a 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-07  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/68560
+       * trans-intrinsic.c (gfc_conv_intrinsic_shape): New function.
+       (gfc_conv_intrinsic_function): Call it.
+
 2018-02-07  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/82049
index 9cc4f3389476ec35a77c196f6c661907edd47e16..337227d3c0897fbe70d5bf12705c566efef632c4 100644 (file)
@@ -5592,6 +5592,22 @@ gfc_conv_intrinsic_ibits (gfc_se * se, gfc_expr * expr)
   se->expr = fold_build2_loc (input_location, BIT_AND_EXPR, type, tmp, mask);
 }
 
+static void
+gfc_conv_intrinsic_shape (gfc_se *se, gfc_expr *expr)
+{
+  gfc_actual_arglist *s, *k;
+  gfc_expr *e;
+
+  /* Remove the KIND argument, if present. */
+  s = expr->value.function.actual;
+  k = s->next;
+  e = k->expr;
+  gfc_free_expr (e);
+  k->expr = NULL;
+
+  gfc_conv_intrinsic_funcall (se, expr);
+}
+
 static void
 gfc_conv_intrinsic_shift (gfc_se * se, gfc_expr * expr, bool right_shift,
                          bool arithmetic)
@@ -8718,6 +8734,10 @@ gfc_conv_intrinsic_function (gfc_se * se, gfc_expr * expr)
              gfc_conv_intrinsic_minmaxloc (se, expr, GT_EXPR);
              break;
 
+           case GFC_ISYM_SHAPE:
+             gfc_conv_intrinsic_shape (se, expr);
+             break;
+
            default:
              gfc_conv_intrinsic_funcall (se, expr);
              break;
index 5191a6b017c6c23862e68ff05bba51f9c0d28b5a..24a99a58ecd8bc3230097c24355aa97313709b56 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-07  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/68560
+       * gfortran.dg/shape_9.f90: New test.
+
 2018-02-07  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/82049
diff --git a/gcc/testsuite/gfortran.dg/shape_9.f90 b/gcc/testsuite/gfortran.dg/shape_9.f90
new file mode 100644 (file)
index 0000000..6d33f97
--- /dev/null
@@ -0,0 +1,16 @@
+! { dg-do  run }
+! { dg-require-effective-target lto }
+! { dg-options "-flto" }
+! Check that there are no warnings with LTO for a KIND argument.
+!
+program test
+   implicit none
+   real, allocatable :: x(:,:)
+
+   allocate(x(2,5))
+   if (any(shape(x) /= [ 2, 5 ])) call abort
+   if (any(shape(x,kind=1) /= [ 2, 5 ])) call abort
+   if (any(shape(x,kind=2) /= [ 2, 5 ])) call abort
+   if (any(shape(x,kind=4) /= [ 2, 5 ])) call abort
+   if (any(shape(x,kind=8) /= [ 2, 5 ])) call abort
+ end program test