From ed019753cb56d0f1b770bcb386e840c9785949d5 Mon Sep 17 00:00:00 2001 From: Francois-Xavier Coudert Date: Wed, 26 Aug 2015 12:37:42 +0000 Subject: [PATCH] re PR fortran/29600 ([F03] MINLOC and MAXLOC take an optional KIND argument) PR fortran/29600 * Makefile.am: Add generated/shape_i{1,2}.c * Makefile.in: Regenerate. * generated/shape_i1.c: New generated file. * generated/shape_i2.c: New generated file. * generated/shape_i4.c: Regenerate. * generated/shape_i8.c: Regenerate. * generated/shape_i16.c: Regenerate. * gfortran.map (GFORTRAN_1.7): Add _gfortran_shape_{1,2}. * m4/shape.m4: Fix parameter type. * gfortran.dg/shape_8.f90: New test. From-SVN: r227210 --- gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/gfortran.dg/shape_8.f90 | 15 ++++++ libgfortran/ChangeLog | 13 ++++++ libgfortran/Makefile.am | 2 + libgfortran/Makefile.in | 21 ++++++++- libgfortran/generated/shape_i1.c | 67 +++++++++++++++++++++++++++ libgfortran/generated/shape_i16.c | 4 +- libgfortran/generated/shape_i2.c | 67 +++++++++++++++++++++++++++ libgfortran/generated/shape_i4.c | 4 +- libgfortran/generated/shape_i8.c | 4 +- libgfortran/gfortran.map | 2 + libgfortran/m4/shape.m4 | 4 +- 12 files changed, 199 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/shape_8.f90 create mode 100644 libgfortran/generated/shape_i1.c create mode 100644 libgfortran/generated/shape_i2.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e8365be37f0..ac549889d7e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-08-26 Francois-Xavier Coudert + + PR fortran/29600 + * gfortran.dg/shape_8.f90: New test. + 2015-08-25 Marek Polacek PR middle-end/67330 diff --git a/gcc/testsuite/gfortran.dg/shape_8.f90 b/gcc/testsuite/gfortran.dg/shape_8.f90 new file mode 100644 index 00000000000..51c6e552b51 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/shape_8.f90 @@ -0,0 +1,15 @@ +! { dg-do run } +! +! Check that we can use SHAPE with optional 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 diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index e3ab51f893e..65e0099a0cd 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,16 @@ +2015-08-26 Francois-Xavier Coudert + + PR fortran/29600 + * Makefile.am: Add generated/shape_i{1,2}.c + * Makefile.in: Regenerate. + * generated/shape_i1.c: New generated file. + * generated/shape_i2.c: New generated file. + * generated/shape_i4.c: Regenerate. + * generated/shape_i8.c: Regenerate. + * generated/shape_i16.c: Regenerate. + * gfortran.map (GFORTRAN_1.7): Add _gfortran_shape_{1,2}. + * m4/shape.m4: Fix parameter type. + 2015-08-26 Francois-Xavier Coudert * libgfortran.h (show_variables): Remove prototype. diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am index e4764337310..39d3e11d223 100644 --- a/libgfortran/Makefile.am +++ b/libgfortran/Makefile.am @@ -483,6 +483,8 @@ $(srcdir)/generated/transpose_c10.c \ $(srcdir)/generated/transpose_c16.c i_shape_c= \ +$(srcdir)/generated/shape_i1.c \ +$(srcdir)/generated/shape_i2.c \ $(srcdir)/generated/shape_i4.c \ $(srcdir)/generated/shape_i8.c \ $(srcdir)/generated/shape_i16.c diff --git a/libgfortran/Makefile.in b/libgfortran/Makefile.in index f0ddb38f5ab..7ed080cf7b0 100644 --- a/libgfortran/Makefile.in +++ b/libgfortran/Makefile.in @@ -259,7 +259,8 @@ am__objects_23 = transpose_i4.lo transpose_i8.lo transpose_i16.lo \ transpose_r4.lo transpose_r8.lo transpose_r10.lo \ transpose_r16.lo transpose_c4.lo transpose_c8.lo \ transpose_c10.lo transpose_c16.lo -am__objects_24 = shape_i4.lo shape_i8.lo shape_i16.lo +am__objects_24 = shape_i1.lo shape_i2.lo shape_i4.lo shape_i8.lo \ + shape_i16.lo am__objects_25 = eoshift1_4.lo eoshift1_8.lo eoshift1_16.lo am__objects_26 = eoshift3_4.lo eoshift3_8.lo eoshift3_16.lo am__objects_27 = cshift1_4.lo cshift1_8.lo cshift1_16.lo @@ -916,6 +917,8 @@ $(srcdir)/generated/transpose_c10.c \ $(srcdir)/generated/transpose_c16.c i_shape_c = \ +$(srcdir)/generated/shape_i1.c \ +$(srcdir)/generated/shape_i2.c \ $(srcdir)/generated/shape_i4.c \ $(srcdir)/generated/shape_i8.c \ $(srcdir)/generated/shape_i16.c @@ -1826,7 +1829,9 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_exponent_r16.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_exponent_r4.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_exponent_r8.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_i1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_i16.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_i2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_i4.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_i8.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signal.Plo@am__quote@ @@ -4016,6 +4021,20 @@ transpose_c16.lo: $(srcdir)/generated/transpose_c16.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o transpose_c16.lo `test -f '$(srcdir)/generated/transpose_c16.c' || echo '$(srcdir)/'`$(srcdir)/generated/transpose_c16.c +shape_i1.lo: $(srcdir)/generated/shape_i1.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT shape_i1.lo -MD -MP -MF $(DEPDIR)/shape_i1.Tpo -c -o shape_i1.lo `test -f '$(srcdir)/generated/shape_i1.c' || echo '$(srcdir)/'`$(srcdir)/generated/shape_i1.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/shape_i1.Tpo $(DEPDIR)/shape_i1.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/generated/shape_i1.c' object='shape_i1.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o shape_i1.lo `test -f '$(srcdir)/generated/shape_i1.c' || echo '$(srcdir)/'`$(srcdir)/generated/shape_i1.c + +shape_i2.lo: $(srcdir)/generated/shape_i2.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT shape_i2.lo -MD -MP -MF $(DEPDIR)/shape_i2.Tpo -c -o shape_i2.lo `test -f '$(srcdir)/generated/shape_i2.c' || echo '$(srcdir)/'`$(srcdir)/generated/shape_i2.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/shape_i2.Tpo $(DEPDIR)/shape_i2.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/generated/shape_i2.c' object='shape_i2.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o shape_i2.lo `test -f '$(srcdir)/generated/shape_i2.c' || echo '$(srcdir)/'`$(srcdir)/generated/shape_i2.c + shape_i4.lo: $(srcdir)/generated/shape_i4.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT shape_i4.lo -MD -MP -MF $(DEPDIR)/shape_i4.Tpo -c -o shape_i4.lo `test -f '$(srcdir)/generated/shape_i4.c' || echo '$(srcdir)/'`$(srcdir)/generated/shape_i4.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/shape_i4.Tpo $(DEPDIR)/shape_i4.Plo diff --git a/libgfortran/generated/shape_i1.c b/libgfortran/generated/shape_i1.c new file mode 100644 index 00000000000..6ac8e14c9b9 --- /dev/null +++ b/libgfortran/generated/shape_i1.c @@ -0,0 +1,67 @@ +/* Implementation of the SHAPE intrinsic + Copyright (C) 2002-2015 Free Software Foundation, Inc. + Contributed by Paul Brook + +This file is part of the GNU Fortran runtime library (libgfortran). + +Libgfortran is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public +License as published by the Free Software Foundation; either +version 3 of the License, or (at your option) any later version. + +Libgfortran is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#include "libgfortran.h" +#include +#include + + +#if defined (HAVE_GFC_INTEGER_1) + +extern void shape_1 (gfc_array_i1 * const restrict ret, + const array_t * const restrict array); +export_proto(shape_1); + +void +shape_1 (gfc_array_i1 * const restrict ret, + const array_t * const restrict array) +{ + int n; + index_type stride; + index_type extent; + int rank; + + rank = GFC_DESCRIPTOR_RANK (array); + + if (ret->base_addr == NULL) + { + GFC_DIMENSION_SET(ret->dim[0], 0, rank - 1, 1); + ret->offset = 0; + ret->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_1)); + } + + stride = GFC_DESCRIPTOR_STRIDE(ret,0); + + if (GFC_DESCRIPTOR_EXTENT(ret,0) < 1) + return; + + for (n = 0; n < rank; n++) + { + extent = GFC_DESCRIPTOR_EXTENT(array,n); + ret->base_addr[n * stride] = extent > 0 ? extent : 0 ; + } +} + +#endif diff --git a/libgfortran/generated/shape_i16.c b/libgfortran/generated/shape_i16.c index a9cb8a25b8e..4cb43c8b5b1 100644 --- a/libgfortran/generated/shape_i16.c +++ b/libgfortran/generated/shape_i16.c @@ -31,12 +31,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #if defined (HAVE_GFC_INTEGER_16) extern void shape_16 (gfc_array_i16 * const restrict ret, - const gfc_array_i16 * const restrict array); + const array_t * const restrict array); export_proto(shape_16); void shape_16 (gfc_array_i16 * const restrict ret, - const gfc_array_i16 * const restrict array) + const array_t * const restrict array) { int n; index_type stride; diff --git a/libgfortran/generated/shape_i2.c b/libgfortran/generated/shape_i2.c new file mode 100644 index 00000000000..982d9ccd92f --- /dev/null +++ b/libgfortran/generated/shape_i2.c @@ -0,0 +1,67 @@ +/* Implementation of the SHAPE intrinsic + Copyright (C) 2002-2015 Free Software Foundation, Inc. + Contributed by Paul Brook + +This file is part of the GNU Fortran runtime library (libgfortran). + +Libgfortran is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public +License as published by the Free Software Foundation; either +version 3 of the License, or (at your option) any later version. + +Libgfortran is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#include "libgfortran.h" +#include +#include + + +#if defined (HAVE_GFC_INTEGER_2) + +extern void shape_2 (gfc_array_i2 * const restrict ret, + const array_t * const restrict array); +export_proto(shape_2); + +void +shape_2 (gfc_array_i2 * const restrict ret, + const array_t * const restrict array) +{ + int n; + index_type stride; + index_type extent; + int rank; + + rank = GFC_DESCRIPTOR_RANK (array); + + if (ret->base_addr == NULL) + { + GFC_DIMENSION_SET(ret->dim[0], 0, rank - 1, 1); + ret->offset = 0; + ret->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_2)); + } + + stride = GFC_DESCRIPTOR_STRIDE(ret,0); + + if (GFC_DESCRIPTOR_EXTENT(ret,0) < 1) + return; + + for (n = 0; n < rank; n++) + { + extent = GFC_DESCRIPTOR_EXTENT(array,n); + ret->base_addr[n * stride] = extent > 0 ? extent : 0 ; + } +} + +#endif diff --git a/libgfortran/generated/shape_i4.c b/libgfortran/generated/shape_i4.c index 04654eae76d..8a912b35b9f 100644 --- a/libgfortran/generated/shape_i4.c +++ b/libgfortran/generated/shape_i4.c @@ -31,12 +31,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #if defined (HAVE_GFC_INTEGER_4) extern void shape_4 (gfc_array_i4 * const restrict ret, - const gfc_array_i4 * const restrict array); + const array_t * const restrict array); export_proto(shape_4); void shape_4 (gfc_array_i4 * const restrict ret, - const gfc_array_i4 * const restrict array) + const array_t * const restrict array) { int n; index_type stride; diff --git a/libgfortran/generated/shape_i8.c b/libgfortran/generated/shape_i8.c index 7b0988875c0..d33add63e47 100644 --- a/libgfortran/generated/shape_i8.c +++ b/libgfortran/generated/shape_i8.c @@ -31,12 +31,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #if defined (HAVE_GFC_INTEGER_8) extern void shape_8 (gfc_array_i8 * const restrict ret, - const gfc_array_i8 * const restrict array); + const array_t * const restrict array); export_proto(shape_8); void shape_8 (gfc_array_i8 * const restrict ret, - const gfc_array_i8 * const restrict array) + const array_t * const restrict array) { int n; index_type stride; diff --git a/libgfortran/gfortran.map b/libgfortran/gfortran.map index 66840639889..5f011de68a1 100644 --- a/libgfortran/gfortran.map +++ b/libgfortran/gfortran.map @@ -1285,6 +1285,8 @@ GFORTRAN_1.7 { __ieee_exceptions_MOD_ieee_support_flag_10; __ieee_exceptions_MOD_ieee_support_flag_16; _gfortran_mvbits_i16; + _gfortran_shape_1; + _gfortran_shape_2; } GFORTRAN_1.6; F2C_1.0 { diff --git a/libgfortran/m4/shape.m4 b/libgfortran/m4/shape.m4 index ffdcebe8d8e..e389d92f00b 100644 --- a/libgfortran/m4/shape.m4 +++ b/libgfortran/m4/shape.m4 @@ -32,12 +32,12 @@ include(iparm.m4)dnl `#if defined (HAVE_'rtype_name`) extern void shape_'rtype_kind` ('rtype` * const restrict ret, - const 'rtype` * const restrict array); + const array_t * const restrict array); export_proto(shape_'rtype_kind`); void shape_'rtype_kind` ('rtype` * const restrict ret, - const 'rtype` * const restrict array) + const array_t * const restrict array) { int n; index_type stride; -- 2.30.2