diff mbox series

Intrinsic documentation for DIM, MOD and MODULO.

Message ID 39df95e3-79a7-c835-9d47-adc45be2bf22@codethink.co.uk
State New
Headers show
Series Intrinsic documentation for DIM, MOD and MODULO. | expand

Commit Message

Mark Eggleston Aug. 19, 2019, 9:11 a.m. UTC
The intrinsics DIM, MOD and MODULO can accept arguments of different 
kinds and return values with the larger of the two kinds. Notes to this 
effect have been added as they were missing from the documentation.

Please find attached the patch.

ChangeLog:

gcc/fortran/ChangeLog

     Mark Eggleston  <mark.eggleston@codethink.com>

     PR fortran/89236
     * intrinsic.texi: Add GNU extension notes to DIM, MOD, MODULO.

Comments

Jeff Law Aug. 19, 2019, 3:08 p.m. UTC | #1
On 8/19/19 3:11 AM, Mark Eggleston wrote:
> The intrinsics DIM, MOD and MODULO can accept arguments of different
> kinds and return values with the larger of the two kinds. Notes to this
> effect have been added as they were missing from the documentation.
> 
> Please find attached the patch.
> 
> ChangeLog:
> 
> gcc/fortran/ChangeLog
> 
>     Mark Eggleston  <mark.eggleston@codethink.com>
> 
>     PR fortran/89236
>     * intrinsic.texi: Add GNU extension notes to DIM, MOD, MODULO.
> 
Do we want to be more specific about what types are accepted as a GNU
extension for these operators?

jeff
Steve Kargl Aug. 19, 2019, 4:19 p.m. UTC | #2
On Mon, Aug 19, 2019 at 09:08:12AM -0600, Jeff Law wrote:
> On 8/19/19 3:11 AM, Mark Eggleston wrote:
> > The intrinsics DIM, MOD and MODULO can accept arguments of different
> > kinds and return values with the larger of the two kinds. Notes to this
> > effect have been added as they were missing from the documentation.
> > 
> > Please find attached the patch.
> > 
> > ChangeLog:
> > 
> > gcc/fortran/ChangeLog
> > 
> >     Mark Eggleston  <mark.eggleston@codethink.com>
> > 
> >     PR fortran/89236
> >     * intrinsic.texi: Add GNU extension notes to DIM, MOD, MODULO.
> > 
> Do we want to be more specific about what types are accepted as a GNU
> extension for these operators?
> 

The current documentation already has that info.

_Arguments_:
     X           The type shall be 'INTEGER' or 'REAL'
     Y           The type shall be the same type and kind as X.

In Fortran standardese, INTEGER means any of the supported
integer kinds (e.g., INTEGER(2)).  X and Y must both be either
INTEGER or REAL, and X and Y must have the same kind type
paramter.  Mark's addition to the manual notes that the
GNU extension allows different kind type parameters, e.g.,

integer(1) i
integer(2) j
...
  k = dim(i,j) 

converts i to an integer(2) before executing the function.

Mark, BTW and IMHO, for minor changes/improvements to the gfortran
documentation, I consider these to be pre-approved.  For
large changes, or if you want someone to proofread a change,
then asking for commit approval is appropriate.
Jeff Law Aug. 19, 2019, 10:47 p.m. UTC | #3
On 8/19/19 10:19 AM, Steve Kargl wrote:
> On Mon, Aug 19, 2019 at 09:08:12AM -0600, Jeff Law wrote:
>> On 8/19/19 3:11 AM, Mark Eggleston wrote:
>>> The intrinsics DIM, MOD and MODULO can accept arguments of different
>>> kinds and return values with the larger of the two kinds. Notes to this
>>> effect have been added as they were missing from the documentation.
>>>
>>> Please find attached the patch.
>>>
>>> ChangeLog:
>>>
>>> gcc/fortran/ChangeLog
>>>
>>>     Mark Eggleston  <mark.eggleston@codethink.com>
>>>
>>>     PR fortran/89236
>>>     * intrinsic.texi: Add GNU extension notes to DIM, MOD, MODULO.
>>>
>> Do we want to be more specific about what types are accepted as a GNU
>> extension for these operators?
>>
> 
> The current documentation already has that info.
Ah, in that case Mark's patch seems like a no-brainer :-)

Jeff
diff mbox series

Patch

From 4e527390271f8002f37b33262bd4b4f90ad2062a Mon Sep 17 00:00:00 2001
From: Mark Eggleston <markeggleston@codethink.com>
Date: Tue, 5 Feb 2019 16:38:10 +0000
Subject: [PATCH] Intrinsic documentation.

---
 gcc/fortran/intrinsic.texi | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index 941c2e39374..4cb0ec8a4cd 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -4876,11 +4876,13 @@  Elemental function
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
 @item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL}
-@item @var{Y} @tab The type shall be the same type and kind as @var{X}.
+@item @var{Y} @tab The type shall be the same type and kind as @var{X}.  (As
+a GNU extension, arguments of different kinds are permitted.)
 @end multitable
 
 @item @emph{Return value}:
-The return value is of type @code{INTEGER} or @code{REAL}.
+The return value is of type @code{INTEGER} or @code{REAL}.  (As a GNU
+extension, kind is the largest kind of the actual arguments.)
 
 @item @emph{Example}:
 @smallexample
@@ -10603,14 +10605,16 @@  Elemental function
 @multitable @columnfractions .15 .70
 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A} 
-and not equal to zero.
+and not equal to zero.  (As a GNU extension, arguments of different kinds are
+permitted.)
 @end multitable
 
 @item @emph{Return value}:
 The return value is the result of @code{A - (INT(A/P) * P)}. The type
 and kind of the return value is the same as that of the arguments. The
 returned value has the same sign as A and a magnitude less than the
-magnitude of P.
+magnitude of P.  (As a GNU extension, kind is the largest kind of the actual
+arguments.)
 
 @item @emph{Example}:
 @smallexample
@@ -10674,11 +10678,13 @@  Elemental function
 @multitable @columnfractions .15 .70
 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}. 
-It shall not be zero.
+It shall not be zero.  (As a GNU extension, arguments of different kinds are
+permitted.)
 @end multitable
 
 @item @emph{Return value}:
-The type and kind of the result are those of the arguments.
+The type and kind of the result are those of the arguments.  (As a GNU
+extension, kind is the largest kind of the actual arguments.)
 @table @asis
 @item If @var{A} and @var{P} are of type @code{INTEGER}:
 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
@@ -12911,7 +12917,7 @@  Elemental function
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
-@item @var{B} @tab Shall be of the same type and kind as @var{A}
+@item @var{B} @tab Shall be of the same type and kind as @var{A}.
 @end multitable
 
 @item @emph{Return value}:
-- 
2.11.0