From e38f293bec375d94eaefb3a43883f802d7b103f0 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Mon, 12 Feb 2018 20:27:11 +0000 Subject: [PATCH] re PR fortran/68560 (The test gfortran.dg/shape_8.f90 now fails when compiled with -flto) 2018-02-12 Thomas Koenig PR fortran/68560 * trans-intrinsic.c (gfc_conv_intrinsic_shape): New function. (gfc_conv_intrinsic_function): Call it. 2018-02-12 Thomas Koenig PR fortran/68560 * gfortran.dg/shape_9.f90: New test. From-SVN: r257603 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/trans-intrinsic.c | 20 ++++++++++++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/shape_9.f90 | 16 ++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/shape_9.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 66ebb310265d..486b7d41394d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2018-02-12 Thomas Koenig + + PR fortran/68560 + * gfortran.dg/shape_9.f90: New test. + 2018-02-12 Francois-Xavier Coudert PR fortran/35299 diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index fea26d15d0fc..e0ecc3d902d6 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -4692,6 +4692,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) @@ -7753,6 +7769,10 @@ gfc_conv_intrinsic_function (gfc_se * se, gfc_expr * expr) conv_generic_with_optional_char_arg (se, expr, 1, 3); break; + case GFC_ISYM_SHAPE: + gfc_conv_intrinsic_shape (se, expr); + break; + default: gfc_conv_intrinsic_funcall (se, expr); break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cb53750fd61b..aba0918751cd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-12 Thomas Koenig + + PR fortran/68560 + * gfortran.dg/shape_9.f90: New test. + 2018-02-12 Francois-Xavier Coudert PR fortran/35299 diff --git a/gcc/testsuite/gfortran.dg/shape_9.f90 b/gcc/testsuite/gfortran.dg/shape_9.f90 new file mode 100644 index 000000000000..6d33f976cb82 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/shape_9.f90 @@ -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 -- 2.47.2