PR fortran/28094
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 24 Jun 2006 08:27:32 +0000 (08:27 +0000)
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 24 Jun 2006 08:27:32 +0000 (08:27 +0000)
* trans-intrinsic.c (gfc_conv_intrinsic_mod): Support cases where
there is no integer kind equal to the resulting real kind.
* intrinsic.c (add_functions): MODULO is not allowed as an actual
argument.

* Makefile.am: Add _mod_r10.F90 and _mod_r16.F90.
* Makefile.in: Regenerate.
* generated/_mod_r10.F90: New file.
* generated/_mod_r16.F90: New file.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114961 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/intrinsic.c
gcc/fortran/trans-intrinsic.c
libgfortran/ChangeLog
libgfortran/Makefile.am
libgfortran/Makefile.in
libgfortran/generated/_mod_r10.F90 [new file with mode: 0644]
libgfortran/generated/_mod_r16.F90 [new file with mode: 0644]

index 3b3584c..73b8f7e 100644 (file)
@@ -1,3 +1,11 @@
+2006-06-24  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR fortran/28094
+       * trans-intrinsic.c (gfc_conv_intrinsic_mod): Support cases where
+       there is no integer kind equal to the resulting real kind.
+       * intrinsic.c (add_functions): MODULO is not allowed as an actual
+       argument.
+
 2006-06-23  Steven G. Kargl  <kargls@comcast.net>
 
        PR fortran/27981
index 46c25f6..082c1b0 100644 (file)
@@ -1809,7 +1809,7 @@ add_functions (void)
 
   make_generic ("mod", GFC_ISYM_MOD, GFC_STD_F77);
 
-  add_sym_2 ("modulo", 1, 1, BT_REAL, di, GFC_STD_F95,
+  add_sym_2 ("modulo", 1, 0, BT_REAL, di, GFC_STD_F95,
             gfc_check_a_p, gfc_simplify_modulo, gfc_resolve_modulo,
             a, BT_REAL, di, REQUIRED, p, BT_REAL, di, REQUIRED);
 
index b4863a0..b23fc5f 100644 (file)
@@ -860,7 +860,7 @@ gfc_conv_intrinsic_mod (gfc_se * se, gfc_expr * expr, int modulo)
   tree test;
   tree test2;
   mpfr_t huge;
-  int n;
+  int n, ikind;
 
   arg = gfc_conv_intrinsic_function_args (se, expr);
   arg2 = TREE_VALUE (TREE_CHAIN (arg));
@@ -886,7 +886,13 @@ gfc_conv_intrinsic_mod (gfc_se * se, gfc_expr * expr, int modulo)
       /* Test if the value is too large to handle sensibly.  */
       gfc_set_model_kind (expr->ts.kind);
       mpfr_init (huge);
-      n = gfc_validate_kind (BT_INTEGER, expr->ts.kind, false);
+      n = gfc_validate_kind (BT_INTEGER, expr->ts.kind, true);
+      ikind = expr->ts.kind;
+      if (n < 0)
+       {
+         n = gfc_validate_kind (BT_INTEGER, gfc_max_integer_kind, false);
+         ikind = gfc_max_integer_kind;
+       }
       mpfr_set_z (huge, gfc_integer_kinds[n].huge, GFC_RND_MODE);
       test = gfc_conv_mpfr_to_tree (huge, expr->ts.kind);
       test2 = build2 (LT_EXPR, boolean_type_node, tmp, test);
@@ -896,7 +902,7 @@ gfc_conv_intrinsic_mod (gfc_se * se, gfc_expr * expr, int modulo)
       test = build2 (GT_EXPR, boolean_type_node, tmp, test);
       test2 = build2 (TRUTH_AND_EXPR, boolean_type_node, test, test2);
 
-      itype = gfc_get_int_type (expr->ts.kind);
+      itype = gfc_get_int_type (ikind);
       if (modulo)
        tmp = build_fix_expr (&se->pre, tmp, itype, FIX_FLOOR_EXPR);
       else
index c03f069..0474b08 100644 (file)
@@ -1,3 +1,11 @@
+2006-06-24  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR fortran/28094
+       * Makefile.am: Add _mod_r10.F90 and _mod_r16.F90.
+       * Makefile.in: Regenerate.
+       * generated/_mod_r10.F90: New file.
+       * generated/_mod_r16.F90: New file.
+
 2006-06-22  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
        PR libfortran/26769
index 22989c8..a7fab63 100644 (file)
@@ -571,11 +571,9 @@ generated/_mod_i4.F90 \
 generated/_mod_i8.F90 \
 generated/_mod_i16.F90 \
 generated/_mod_r4.F90 \
-generated/_mod_r8.F90
-# There are commented out due to a bug in the way the front-end
-# handles MOD
-#generated/_mod_r10.F90
-#generated/_mod_r16.F90
+generated/_mod_r8.F90 \
+generated/_mod_r10.F90 \
+generated/_mod_r16.F90
 
 gfor_specific_src= \
 $(gfor_built_specific_src) \
index f8e0bd3..29844fb 100644 (file)
@@ -205,7 +205,8 @@ am__objects_36 = _sign_i4.lo _sign_i8.lo _sign_i16.lo _sign_r4.lo \
        _sign_r8.lo _sign_r10.lo _sign_r16.lo _dim_i4.lo _dim_i8.lo \
        _dim_i16.lo _dim_r4.lo _dim_r8.lo _dim_r10.lo _dim_r16.lo \
        _atan2_r4.lo _atan2_r8.lo _atan2_r10.lo _atan2_r16.lo \
-       _mod_i4.lo _mod_i8.lo _mod_i16.lo _mod_r4.lo _mod_r8.lo
+       _mod_i4.lo _mod_i8.lo _mod_i16.lo _mod_r4.lo _mod_r8.lo \
+       _mod_r10.lo _mod_r16.lo
 am__objects_37 = $(am__objects_35) $(am__objects_36) dprod_r8.lo \
        f2c_specifics.lo
 am_libgfortran_la_OBJECTS = $(am__objects_1) $(am__objects_31) \
@@ -920,12 +921,10 @@ generated/_mod_i4.F90 \
 generated/_mod_i8.F90 \
 generated/_mod_i16.F90 \
 generated/_mod_r4.F90 \
-generated/_mod_r8.F90
+generated/_mod_r8.F90 \
+generated/_mod_r10.F90 \
+generated/_mod_r16.F90
 
-# There are commented out due to a bug in the way the front-end
-# handles MOD
-#generated/_mod_r10.F90
-#generated/_mod_r16.F90
 gfor_specific_src = \
 $(gfor_built_specific_src) \
 $(gfor_built_specific2_src) \
@@ -1398,6 +1397,12 @@ _mod_r4.lo: generated/_mod_r4.F90
 _mod_r8.lo: generated/_mod_r8.F90
        $(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _mod_r8.lo `test -f 'generated/_mod_r8.F90' || echo '$(srcdir)/'`generated/_mod_r8.F90
 
+_mod_r10.lo: generated/_mod_r10.F90
+       $(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _mod_r10.lo `test -f 'generated/_mod_r10.F90' || echo '$(srcdir)/'`generated/_mod_r10.F90
+
+_mod_r16.lo: generated/_mod_r16.F90
+       $(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o _mod_r16.lo `test -f 'generated/_mod_r16.F90' || echo '$(srcdir)/'`generated/_mod_r16.F90
+
 f2c_specifics.lo: intrinsics/f2c_specifics.F90
        $(LIBTOOL) --mode=compile $(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) -c -o f2c_specifics.lo `test -f 'intrinsics/f2c_specifics.F90' || echo '$(srcdir)/'`intrinsics/f2c_specifics.F90
 
diff --git a/libgfortran/generated/_mod_r10.F90 b/libgfortran/generated/_mod_r10.F90
new file mode 100644 (file)
index 0000000..9826d12
--- /dev/null
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU 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 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU 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.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_REAL_10)
+
+
+
+elemental function specific__mod_r10 (p1, p2)
+   real (kind=10), intent (in) :: p1, p2
+   real (kind=10) :: specific__mod_r10
+
+   specific__mod_r10 = mod (p1, p2)
+end function
+
+
+
+#endif
diff --git a/libgfortran/generated/_mod_r16.F90 b/libgfortran/generated/_mod_r16.F90
new file mode 100644 (file)
index 0000000..15c2b81
--- /dev/null
@@ -0,0 +1,51 @@
+!   Copyright 2002 Free Software Foundation, Inc.
+!   Contributed by Paul Brook <paul@nowt.org>
+!
+!This file is part of the GNU Fortran 95 runtime library (libgfortran).
+!
+!GNU 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 2 of the License, or (at your option) any later version.
+
+!In addition to the permissions in the GNU General Public License, the
+!Free Software Foundation gives you unlimited permission to link the
+!compiled version of this file into combinations with other programs,
+!and to distribute those combinations without any restriction coming
+!from the use of this file.  (The General Public License restrictions
+!do apply in other respects; for example, they cover modification of
+!the file, and distribution when not linked into a combine
+!executable.)
+!
+!GNU 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.
+!
+!You should have received a copy of the GNU General Public
+!License along with libgfortran; see the file COPYING.  If not,
+!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+!Boston, MA 02110-1301, USA.
+!
+!This file is machine generated.
+
+
+
+#include "config.h"
+#include "kinds.inc"
+#include "c99_protos.inc"
+
+#if defined (HAVE_GFC_REAL_16)
+
+
+
+elemental function specific__mod_r16 (p1, p2)
+   real (kind=16), intent (in) :: p1, p2
+   real (kind=16) :: specific__mod_r16
+
+   specific__mod_r16 = mod (p1, p2)
+end function
+
+
+
+#endif