Re: [PATCH PR Fortran/89286] Intrinsic sign and GNU Extension

2019-07-22 Thread Jeff Law
On 7/10/19 7:50 AM, Mark Eggleston wrote:
> The attached patch treats the intrinsic SIGN in the same way as MOD and
> DIM as it has the same arguments.
> 
> Tested using make -j 8 check-fortran on x86_64
> 
> Conditional compilation using #ifdef __GFC_REAL_16__ has been employed
> where appropriate in the test cases so should be OK on platforms without
> REAL(16).
> 
> Change logs:
> 
> gcc/fortran
> 
>     Mark Eggleston  
> 
>     PR fortran/89286
>     * check.c (gfc_check_sign): Deleted.
>     * intrinsic.c (add_functions): Call add_sym_2 with gfc_check_a_p
>     instead of gfc_check_sign for "sign".
>     * intrinsic.h: Remove declaration of gfc_check_sign.
>     * iresolve.c (gfc_resolve_sign): Check for largest kind of the actual
>     arguments and convert the smaller. Set return kind to be the largest.
>     * simplify.c (gfc_simplify_sign): Use the largest kind of the actual
>     arguments for return
>     * intrinsic.texi: Add GNU extension notes for return value to SIGN.
> 
> gcc/testsuite
> 
>     Mark Eggleston 
> 
>     PR fortran/89240
>     * gfortran.dg/sign_gnu_extension_1.f90: New test.
>     * gfortran.dg/sign_gnu_extension_2.f90: New test.
>     * gfortran.dg/pr78619.f90: Check for "must have" instead of "must be".
> 
> If OK please can someone commit as I do not have the privileges.
> 
So FWIW, this is in my tester now too.

jeff


Re: [PATCH PR Fortran/89286] Intrinsic sign and GNU Extension

2019-07-22 Thread Jeff Law
On 7/11/19 6:16 AM, Mark Eggleston wrote:
> 
> On 10/07/2019 17:20, Bernhard Reutner-Fischer wrote:
>> On 10 July 2019 17:52:40 CEST, Steve Kargl
>>  wrote:
>>> On Wed, Jul 10, 2019 at 02:50:47PM +0100, Mark Eggleston wrote:
 The attached patch treats the intrinsic SIGN in the same way as MOD
>>> and
 DIM as it has the same arguments.

 Tested using make -j 8 check-fortran on x86_64

 Conditional compilation using #ifdef __GFC_REAL_16__ has been
>>> employed
 where appropriate in the test cases so should be OK on platforms
>>> without
 REAL(16).

 Change logs:

 gcc/fortran

       Mark Eggleston  

       PR fortran/89286
       * check.c (gfc_check_sign): Deleted.
>> ChangeLog has to be in present tense per convention.
>>
       * intrinsic.c (add_functions): Call add_sym_2 with gfc_check_a_p
       instead of gfc_check_sign for "sign".
       * intrinsic.h: Remove declaration of gfc_check_sign.
       * iresolve.c (gfc_resolve_sign): Check for largest kind of the
>>> actual
       arguments and convert the smaller. Set return kind to be the
>>> largest.
       * simplify.c (gfc_simplify_sign): Use the largest kind of the
>>> actual
       arguments for return
       * intrinsic.texi: Add GNU extension notes for return value to
>>> SIGN.
 gcc/testsuite

       Mark Eggleston 

       PR fortran/89240
       * gfortran.dg/sign_gnu_extension_1.f90: New test.
       * gfortran.dg/sign_gnu_extension_2.f90: New test.
       * gfortran.dg/pr78619.f90: Check for "must have" instead of
>>> "must be".
 If OK please can someone commit as I do not have the privileges.

>>> We really need to get you commit access to the tree.
>>>
>>> I also am not a fan of this type of change.  Having spent the
>>> last few days working on fixing BOZ to conform to F2018, I'm
>>> finding all sorts of undocumented "extensions".  Personally,
>>> I think gfortran should be moving towards the standard by
>>> deprecating of these types of extensions.
> 
> I agree.
> 
> I think that -std=gnu should not be the default, if gnu extensions are
> required you have to ask for them.
> 
>> At least make them explicit under explicit extension or at least
>> -legacy or whatever its called.
>>
>> thanks,
> 
> I agree, at the moment the GNU extension is silently supported by DIM
> and MOD
So if Mark was to put this behavior behind the -fdec or whatever the
appropriate switch is, could this move forward?

jeff


Re: [PATCH PR Fortran/89286] Intrinsic sign and GNU Extension

2019-07-22 Thread Jeff Law
On 7/10/19 9:52 AM, Steve Kargl wrote:
> On Wed, Jul 10, 2019 at 02:50:47PM +0100, Mark Eggleston wrote:
>> The attached patch treats the intrinsic SIGN in the same way as MOD and 
>> DIM as it has the same arguments.
>>
>> Tested using make -j 8 check-fortran on x86_64
>>
>> Conditional compilation using #ifdef __GFC_REAL_16__ has been employed 
>> where appropriate in the test cases so should be OK on platforms without 
>> REAL(16).
>>
>> Change logs:
>>
>> gcc/fortran
>>
>>      Mark Eggleston  
>>
>>      PR fortran/89286
>>      * check.c (gfc_check_sign): Deleted.
>>      * intrinsic.c (add_functions): Call add_sym_2 with gfc_check_a_p
>>      instead of gfc_check_sign for "sign".
>>      * intrinsic.h: Remove declaration of gfc_check_sign.
>>      * iresolve.c (gfc_resolve_sign): Check for largest kind of the actual
>>      arguments and convert the smaller. Set return kind to be the largest.
>>      * simplify.c (gfc_simplify_sign): Use the largest kind of the actual
>>      arguments for return
>>      * intrinsic.texi: Add GNU extension notes for return value to SIGN.
>>
>> gcc/testsuite
>>
>>      Mark Eggleston 
>>
>>      PR fortran/89240
>>      * gfortran.dg/sign_gnu_extension_1.f90: New test.
>>      * gfortran.dg/sign_gnu_extension_2.f90: New test.
>>      * gfortran.dg/pr78619.f90: Check for "must have" instead of "must be".
>>
>> If OK please can someone commit as I do not have the privileges.
>>
> 
> We really need to get you commit access to the tree.
I will handle that directly with Mark.

> 
> I also am not a fan of this type of change.  Having spent the
> last few days working on fixing BOZ to conform to F2018, I'm
> finding all sorts of undocumented "extensions".  Personally,
> I think gfortran should be moving towards the standard by
> deprecating of these types of extensions.
I'd tend to agree.  The problem is getting real world codebases moved
can be exceedingly difficult.  At the very least these extensions should
be behind suitable flags IMHO.

jeff



Re: [PATCH PR Fortran/89286] Intrinsic sign and GNU Extension

2019-07-11 Thread Mark Eggleston



On 10/07/2019 17:20, Bernhard Reutner-Fischer wrote:

On 10 July 2019 17:52:40 CEST, Steve Kargl  
wrote:

On Wed, Jul 10, 2019 at 02:50:47PM +0100, Mark Eggleston wrote:

The attached patch treats the intrinsic SIGN in the same way as MOD

and

DIM as it has the same arguments.

Tested using make -j 8 check-fortran on x86_64

Conditional compilation using #ifdef __GFC_REAL_16__ has been

employed

where appropriate in the test cases so should be OK on platforms

without

REAL(16).

Change logs:

gcc/fortran

      Mark Eggleston  

      PR fortran/89286
      * check.c (gfc_check_sign): Deleted.

ChangeLog has to be in present tense per convention.


      * intrinsic.c (add_functions): Call add_sym_2 with gfc_check_a_p
      instead of gfc_check_sign for "sign".
      * intrinsic.h: Remove declaration of gfc_check_sign.
      * iresolve.c (gfc_resolve_sign): Check for largest kind of the

actual

      arguments and convert the smaller. Set return kind to be the

largest.

      * simplify.c (gfc_simplify_sign): Use the largest kind of the

actual

      arguments for return
      * intrinsic.texi: Add GNU extension notes for return value to

SIGN.

gcc/testsuite

      Mark Eggleston 

      PR fortran/89240
      * gfortran.dg/sign_gnu_extension_1.f90: New test.
      * gfortran.dg/sign_gnu_extension_2.f90: New test.
      * gfortran.dg/pr78619.f90: Check for "must have" instead of

"must be".

If OK please can someone commit as I do not have the privileges.


We really need to get you commit access to the tree.

I also am not a fan of this type of change.  Having spent the
last few days working on fixing BOZ to conform to F2018, I'm
finding all sorts of undocumented "extensions".  Personally,
I think gfortran should be moving towards the standard by
deprecating of these types of extensions.


I agree.

I think that -std=gnu should not be the default, if gnu extensions are 
required you have to ask for them.



At least make them explicit under explicit extension or at least -legacy or 
whatever its called.

thanks,


I agree, at the moment the GNU extension is silently supported by DIM 
and MOD






--
https://www.codethink.co.uk/privacy.html



Re: [PATCH PR Fortran/89286] Intrinsic sign and GNU Extension

2019-07-10 Thread Bernhard Reutner-Fischer
On 10 July 2019 17:52:40 CEST, Steve Kargl  
wrote:
>On Wed, Jul 10, 2019 at 02:50:47PM +0100, Mark Eggleston wrote:
>> The attached patch treats the intrinsic SIGN in the same way as MOD
>and 
>> DIM as it has the same arguments.
>> 
>> Tested using make -j 8 check-fortran on x86_64
>> 
>> Conditional compilation using #ifdef __GFC_REAL_16__ has been
>employed 
>> where appropriate in the test cases so should be OK on platforms
>without 
>> REAL(16).
>> 
>> Change logs:
>> 
>> gcc/fortran
>> 
>>      Mark Eggleston  
>> 
>>      PR fortran/89286
>>      * check.c (gfc_check_sign): Deleted.

ChangeLog has to be in present tense per convention.

>>      * intrinsic.c (add_functions): Call add_sym_2 with gfc_check_a_p
>>      instead of gfc_check_sign for "sign".
>>      * intrinsic.h: Remove declaration of gfc_check_sign.
>>      * iresolve.c (gfc_resolve_sign): Check for largest kind of the
>actual
>>      arguments and convert the smaller. Set return kind to be the
>largest.
>>      * simplify.c (gfc_simplify_sign): Use the largest kind of the
>actual
>>      arguments for return
>>      * intrinsic.texi: Add GNU extension notes for return value to
>SIGN.
>> 
>> gcc/testsuite
>> 
>>      Mark Eggleston 
>> 
>>      PR fortran/89240
>>      * gfortran.dg/sign_gnu_extension_1.f90: New test.
>>      * gfortran.dg/sign_gnu_extension_2.f90: New test.
>>      * gfortran.dg/pr78619.f90: Check for "must have" instead of
>"must be".
>> 
>> If OK please can someone commit as I do not have the privileges.
>> 
>
>We really need to get you commit access to the tree.
>
>I also am not a fan of this type of change.  Having spent the
>last few days working on fixing BOZ to conform to F2018, I'm
>finding all sorts of undocumented "extensions".  Personally,
>I think gfortran should be moving towards the standard by
>deprecating of these types of extensions.

At least make them explicit under explicit extension or at least -legacy or 
whatever its called.

thanks,



Re: [PATCH PR Fortran/89286] Intrinsic sign and GNU Extension

2019-07-10 Thread Steve Kargl
On Wed, Jul 10, 2019 at 02:50:47PM +0100, Mark Eggleston wrote:
> The attached patch treats the intrinsic SIGN in the same way as MOD and 
> DIM as it has the same arguments.
> 
> Tested using make -j 8 check-fortran on x86_64
> 
> Conditional compilation using #ifdef __GFC_REAL_16__ has been employed 
> where appropriate in the test cases so should be OK on platforms without 
> REAL(16).
> 
> Change logs:
> 
> gcc/fortran
> 
>      Mark Eggleston  
> 
>      PR fortran/89286
>      * check.c (gfc_check_sign): Deleted.
>      * intrinsic.c (add_functions): Call add_sym_2 with gfc_check_a_p
>      instead of gfc_check_sign for "sign".
>      * intrinsic.h: Remove declaration of gfc_check_sign.
>      * iresolve.c (gfc_resolve_sign): Check for largest kind of the actual
>      arguments and convert the smaller. Set return kind to be the largest.
>      * simplify.c (gfc_simplify_sign): Use the largest kind of the actual
>      arguments for return
>      * intrinsic.texi: Add GNU extension notes for return value to SIGN.
> 
> gcc/testsuite
> 
>      Mark Eggleston 
> 
>      PR fortran/89240
>      * gfortran.dg/sign_gnu_extension_1.f90: New test.
>      * gfortran.dg/sign_gnu_extension_2.f90: New test.
>      * gfortran.dg/pr78619.f90: Check for "must have" instead of "must be".
> 
> If OK please can someone commit as I do not have the privileges.
> 

We really need to get you commit access to the tree.

I also am not a fan of this type of change.  Having spent the
last few days working on fixing BOZ to conform to F2018, I'm
finding all sorts of undocumented "extensions".  Personally,
I think gfortran should be moving towards the standard by
deprecating of these types of extensions.

-- 
Steve


[PATCH PR Fortran/89286] Intrinsic sign and GNU Extension

2019-07-10 Thread Mark Eggleston
The attached patch treats the intrinsic SIGN in the same way as MOD and 
DIM as it has the same arguments.


Tested using make -j 8 check-fortran on x86_64

Conditional compilation using #ifdef __GFC_REAL_16__ has been employed 
where appropriate in the test cases so should be OK on platforms without 
REAL(16).


Change logs:

gcc/fortran

    Mark Eggleston  

    PR fortran/89286
    * check.c (gfc_check_sign): Deleted.
    * intrinsic.c (add_functions): Call add_sym_2 with gfc_check_a_p
    instead of gfc_check_sign for "sign".
    * intrinsic.h: Remove declaration of gfc_check_sign.
    * iresolve.c (gfc_resolve_sign): Check for largest kind of the actual
    arguments and convert the smaller. Set return kind to be the largest.
    * simplify.c (gfc_simplify_sign): Use the largest kind of the actual
    arguments for return
    * intrinsic.texi: Add GNU extension notes for return value to SIGN.

gcc/testsuite

    Mark Eggleston 

    PR fortran/89240
    * gfortran.dg/sign_gnu_extension_1.f90: New test.
    * gfortran.dg/sign_gnu_extension_2.f90: New test.
    * gfortran.dg/pr78619.f90: Check for "must have" instead of "must be".

If OK please can someone commit as I do not have the privileges.

--
https://www.codethink.co.uk/privacy.html

>From 59069e6053f8b178d6f981f02e4b33701ae78062 Mon Sep 17 00:00:00 2001
From: Mark Eggleston 
Date: Thu, 31 Jan 2019 13:36:48 +
Subject: [PATCH 01/12] Intrinsic sign and GNU extension.

The intrinsic sign has the same parameters as other intrinsics such as
dim and mod. This support is part of the GNU extension enabled by using
-std=gnu (the default).
---
 gcc/fortran/check.c|  14 ---
 gcc/fortran/intrinsic.c|   2 +-
 gcc/fortran/intrinsic.h|   1 -
 gcc/fortran/intrinsic.texi |   6 +-
 gcc/fortran/iresolve.c |  13 +++
 gcc/fortran/simplify.c |   4 +-
 gcc/testsuite/gfortran.dg/pr78619.f90  |   2 +-
 gcc/testsuite/gfortran.dg/sign-gnu-extension_1.f90 | 103 +
 gcc/testsuite/gfortran.dg/sign-gnu-extension_2.f90 |  70 ++
 9 files changed, 195 insertions(+), 20 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/sign-gnu-extension_1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/sign-gnu-extension_2.f90

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 95801804022..a7c5a6ef2a1 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -4484,20 +4484,6 @@ gfc_check_shift (gfc_expr *i, gfc_expr *shift)
   return true;
 }
 
-
-bool
-gfc_check_sign (gfc_expr *a, gfc_expr *b)
-{
-  if (!int_or_real_check (a, 0))
-return false;
-
-  if (!same_type_check (a, 0, b, 1))
-return false;
-
-  return true;
-}
-
-
 bool
 gfc_check_size (gfc_expr *array, gfc_expr *dim, gfc_expr *kind)
 {
diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
index c21fbddd5fb..fd10c48f1cf 100644
--- a/gcc/fortran/intrinsic.c
+++ b/gcc/fortran/intrinsic.c
@@ -2930,7 +2930,7 @@ add_functions (void)
   make_generic ("shiftr", GFC_ISYM_SHIFTR, GFC_STD_F2008);
 
   add_sym_2 ("sign", GFC_ISYM_SIGN, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
-	 gfc_check_sign, gfc_simplify_sign, gfc_resolve_sign,
+	 gfc_check_a_p, gfc_simplify_sign, gfc_resolve_sign,
 	 a, BT_REAL, dr, REQUIRED, b, BT_REAL, dr, REQUIRED);
 
   add_sym_2 ("isign", GFC_ISYM_SIGN, CLASS_ELEMENTAL, ACTUAL_YES, BT_INTEGER, di, GFC_STD_F77,
diff --git a/gcc/fortran/intrinsic.h b/gcc/fortran/intrinsic.h
index 0c60dab8390..83be8b38bdf 100644
--- a/gcc/fortran/intrinsic.h
+++ b/gcc/fortran/intrinsic.h
@@ -154,7 +154,6 @@ bool gfc_check_set_exponent (gfc_expr *, gfc_expr *);
 bool gfc_check_shape (gfc_expr *, gfc_expr *);
 bool gfc_check_shift (gfc_expr *, gfc_expr *);
 bool gfc_check_size (gfc_expr *, gfc_expr *, gfc_expr *);
-bool gfc_check_sign (gfc_expr *, gfc_expr *);
 bool gfc_check_signal (gfc_expr *, gfc_expr *);
 bool gfc_check_sizeof (gfc_expr *);
 bool gfc_check_c_associated (gfc_expr *, gfc_expr *);
diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index f390761dc3d..c336cfccb3c 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -12917,11 +12917,13 @@ 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}.  (As a GNU
+extension, arguments of different kinds are permitted.)
 @end multitable
 
 @item @emph{Return value}:
-The kind of the return value is that of @var{A} and @var{B}.
+The kind of the return value is that of @var{A} and @var{B}.  (As a GNU
+extension, kind is the largest kind of the actual arguments.)
 If @math{B\ge 0} then the result is @code{ABS(A)}, else
 it is @code{-ABS(A)}.