]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fortran: Add degree based trig functions for F2023
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Thu, 14 Dec 2023 03:04:50 +0000 (19:04 -0800)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Thu, 14 Dec 2023 18:37:11 +0000 (10:37 -0800)
PR fortran/112873

gcc/fortran/ChangeLog:

* gfortran.texi: Update to reflect the changes.
* intrinsic.cc (add_functions): Update the standard that the
various  degree trigonometric functions have been described in.
(gfc_check_intrinsic_standard): Add an error string for F2023.
* intrinsic.texi: Update accordingly.

gcc/fortran/gfortran.texi
gcc/fortran/intrinsic.cc
gcc/fortran/intrinsic.texi

index c29cb786279c57b4f703745592f7fdc9806659b5..286c298d1b44fb785e9fdd80305c8aebbbde4714 100644 (file)
@@ -1239,7 +1239,6 @@ additional compatibility extensions along with those enabled by
 * UNION and MAP::
 * Type variants for integer intrinsics::
 * AUTOMATIC and STATIC attributes::
-* Extended math intrinsics::
 * Form feed as whitespace::
 * TYPE as an alias for PRINT::
 * %LOC as an rvalue::
@@ -2317,42 +2316,6 @@ subroutine f
 endsubroutine
 @end example
 
-@node Extended math intrinsics
-@subsection Extended math intrinsics
-@cindex intrinsics, math
-@cindex intrinsics, trigonometric functions
-
-GNU Fortran supports an extended list of mathematical intrinsics with the
-compile flag @option{-fdec-math} for compatability with legacy code.
-These intrinsics are described fully in @ref{Intrinsic Procedures} where it is
-noted that they are extensions and should be avoided whenever possible.
-
-Specifically, @option{-fdec-math} enables the @ref{COTAN} intrinsic, and
-trigonometric intrinsics which accept or produce values in degrees instead of
-radians.  Here is a summary of the new intrinsics:
-
-@multitable @columnfractions .5 .5
-@headitem Radians @tab Degrees
-@item @code{@ref{ACOS}}   @tab @code{@ref{ACOSD}}*
-@item @code{@ref{ASIN}}   @tab @code{@ref{ASIND}}*
-@item @code{@ref{ATAN}}   @tab @code{@ref{ATAND}}*
-@item @code{@ref{ATAN2}}  @tab @code{@ref{ATAN2D}}*
-@item @code{@ref{COS}}    @tab @code{@ref{COSD}}*
-@item @code{@ref{COTAN}}* @tab @code{@ref{COTAND}}*
-@item @code{@ref{SIN}}    @tab @code{@ref{SIND}}*
-@item @code{@ref{TAN}}    @tab @code{@ref{TAND}}*
-@end multitable
-
-* Enabled with @option{-fdec-math}.
-
-For advanced users, it may be important to know the implementation of these
-functions. They are simply wrappers around the standard radian functions, which
-have more accurate builtin versions. These functions convert their arguments
-(or results) to degrees (or radians) by taking the value modulus 360 (or 2*pi)
-and then multiplying it by a constant radian-to-degree (or degree-to-radian)
-factor, as appropriate. The factor is computed at compile-time as 180/pi (or
-pi/180).
-
 @node Form feed as whitespace
 @subsection Form feed as whitespace
 @cindex form feed whitespace
index 74970e567fcba9d46a0be1ab1def7260d531c8cc..8d170dd4cb70e2c5746f6bab2f37b3abadce77b1 100644 (file)
@@ -3310,72 +3310,75 @@ add_functions (void)
   make_generic ("loc", GFC_ISYM_LOC, GFC_STD_GNU);
 
 
-  /* The next of intrinsic subprogram are the degree trigonometric functions.
-     These were hidden behind the -fdec-math option, but are now simply
-     included as extensions to the set of intrinsic subprograms.  */
+  /* The degree trigonometric functions were added as part of the DEC
+     Fortran compatibility effort, and were hidden behind a -fdec-math
+     option.  Fortran 2023 has added some of these functions to Fortran
+     standard as generic subprogram, e.g., acosd() is added while dacosd()
+     is not.  So, update GFC_STD_GNU to GFC_STD_F2023 for the generic
+     functions.  */
 
   add_sym_1 ("acosd", GFC_ISYM_ACOSD, CLASS_ELEMENTAL, ACTUAL_YES,
-            BT_REAL, dr, GFC_STD_GNU,
+            BT_REAL, dr, GFC_STD_F2023,
             gfc_check_fn_r, gfc_simplify_acosd, gfc_resolve_trigd,
             x, BT_REAL, dr, REQUIRED);
 
+  make_generic ("acosd", GFC_ISYM_ACOSD, GFC_STD_F2023);
+
   add_sym_1 ("dacosd", GFC_ISYM_ACOSD, CLASS_ELEMENTAL, ACTUAL_YES,
             BT_REAL, dd, GFC_STD_GNU,
             gfc_check_fn_d, gfc_simplify_acosd, gfc_resolve_trigd,
             x, BT_REAL, dd, REQUIRED);
 
-  make_generic ("acosd", GFC_ISYM_ACOSD, GFC_STD_GNU);
-
   add_sym_1 ("asind", GFC_ISYM_ASIND, CLASS_ELEMENTAL, ACTUAL_YES,
-            BT_REAL, dr, GFC_STD_GNU,
+            BT_REAL, dr, GFC_STD_F2023,
             gfc_check_fn_r, gfc_simplify_asind, gfc_resolve_trigd,
             x, BT_REAL, dr, REQUIRED);
 
+  make_generic ("asind", GFC_ISYM_ASIND, GFC_STD_F2023);
+
   add_sym_1 ("dasind", GFC_ISYM_ASIND, CLASS_ELEMENTAL, ACTUAL_YES,
             BT_REAL, dd, GFC_STD_GNU,
             gfc_check_fn_d, gfc_simplify_asind, gfc_resolve_trigd,
             x, BT_REAL, dd, REQUIRED);
 
-  make_generic ("asind", GFC_ISYM_ASIND, GFC_STD_GNU);
-
   add_sym_1 ("atand", GFC_ISYM_ATAND, CLASS_ELEMENTAL, ACTUAL_YES,
-            BT_REAL, dr, GFC_STD_GNU,
+            BT_REAL, dr, GFC_STD_F2023,
             gfc_check_fn_r, gfc_simplify_atand, gfc_resolve_trigd,
             x, BT_REAL, dr, REQUIRED);
 
+  make_generic ("atand", GFC_ISYM_ATAND, GFC_STD_F2023);
+
   add_sym_1 ("datand", GFC_ISYM_ATAND, CLASS_ELEMENTAL, ACTUAL_YES,
             BT_REAL, dd, GFC_STD_GNU,
             gfc_check_fn_d, gfc_simplify_atand, gfc_resolve_trigd,
             x, BT_REAL, dd, REQUIRED);
 
-  make_generic ("atand", GFC_ISYM_ATAND, GFC_STD_GNU);
-
   add_sym_2 ("atan2d", GFC_ISYM_ATAN2D, CLASS_ELEMENTAL, ACTUAL_YES,
-            BT_REAL, dr, GFC_STD_GNU,
+            BT_REAL, dr, GFC_STD_F2023,
             gfc_check_atan2, gfc_simplify_atan2d, gfc_resolve_trigd2,
             y, BT_REAL, dr, REQUIRED,
             x, BT_REAL, dr, REQUIRED);
 
+  make_generic ("atan2d", GFC_ISYM_ATAN2D, GFC_STD_F2023);
+
   add_sym_2 ("datan2d", GFC_ISYM_ATAN2D, CLASS_ELEMENTAL, ACTUAL_YES,
             BT_REAL, dd, GFC_STD_GNU,
             gfc_check_datan2, gfc_simplify_atan2d, gfc_resolve_trigd2,
             y, BT_REAL, dd, REQUIRED,
             x, BT_REAL, dd, REQUIRED);
 
-  make_generic ("atan2d", GFC_ISYM_ATAN2D, GFC_STD_GNU);
-
   add_sym_1 ("cosd", GFC_ISYM_COSD, CLASS_ELEMENTAL, ACTUAL_YES,
-            BT_REAL, dr, GFC_STD_GNU,
+            BT_REAL, dr, GFC_STD_F2023,
             gfc_check_fn_r, gfc_simplify_cosd, gfc_resolve_trigd,
             x, BT_REAL, dr, REQUIRED);
 
+  make_generic ("cosd", GFC_ISYM_COSD, GFC_STD_F2023);
+
   add_sym_1 ("dcosd", GFC_ISYM_COSD, CLASS_ELEMENTAL, ACTUAL_YES,
             BT_REAL, dd, GFC_STD_GNU,
             gfc_check_fn_d, gfc_simplify_cosd, gfc_resolve_trigd,
             x, BT_REAL, dd, REQUIRED);
 
-  make_generic ("cosd", GFC_ISYM_COSD, GFC_STD_GNU);
-
   add_sym_1 ("cotan", GFC_ISYM_COTAN, CLASS_ELEMENTAL, ACTUAL_YES,
             BT_REAL, dr, GFC_STD_GNU,
             gfc_check_fn_rc2008, gfc_simplify_cotan, gfc_resolve_trigd,
@@ -3411,29 +3414,29 @@ add_functions (void)
   make_generic ("cotand", GFC_ISYM_COTAND, GFC_STD_GNU);
 
   add_sym_1 ("sind", GFC_ISYM_SIND, CLASS_ELEMENTAL, ACTUAL_YES,
-            BT_REAL, dr, GFC_STD_GNU,
+            BT_REAL, dr, GFC_STD_F2023,
             gfc_check_fn_r, gfc_simplify_sind, gfc_resolve_trigd,
             x, BT_REAL, dr, REQUIRED);
 
+  make_generic ("sind", GFC_ISYM_SIND, GFC_STD_F2023);
+
   add_sym_1 ("dsind", GFC_ISYM_SIND, CLASS_ELEMENTAL, ACTUAL_YES,
             BT_REAL, dd, GFC_STD_GNU,
             gfc_check_fn_d, gfc_simplify_sind, gfc_resolve_trigd,
             x, BT_REAL, dd, REQUIRED);
 
-  make_generic ("sind", GFC_ISYM_SIND, GFC_STD_GNU);
-
   add_sym_1 ("tand", GFC_ISYM_TAND, CLASS_ELEMENTAL, ACTUAL_YES,
-            BT_REAL, dr, GFC_STD_GNU,
+            BT_REAL, dr, GFC_STD_F2023,
             gfc_check_fn_r, gfc_simplify_tand, gfc_resolve_trigd,
             x, BT_REAL, dr, REQUIRED);
 
+  make_generic ("tand", GFC_ISYM_TAND, GFC_STD_F2023);
+
   add_sym_1 ("dtand", GFC_ISYM_TAND, CLASS_ELEMENTAL, ACTUAL_YES,
             BT_REAL, dd, GFC_STD_GNU,
             gfc_check_fn_d, gfc_simplify_tand, gfc_resolve_trigd,
             x, BT_REAL, dd, REQUIRED);
 
-  make_generic ("tand", GFC_ISYM_TAND, GFC_STD_GNU);
-
   /* The following function is internally used for coarray libray functions.
      "make_from_module" makes it inaccessible for external users.  */
   add_sym_1 (GFC_PREFIX ("caf_get"), GFC_ISYM_CAF_GET, CLASS_IMPURE, ACTUAL_NO,
@@ -4889,6 +4892,10 @@ gfc_check_intrinsic_standard (const gfc_intrinsic_sym* isym,
       symstd_msg = _("new in Fortran 2018");
       break;
 
+    case GFC_STD_F2023:
+      symstd_msg = _("new in Fortran 2023");
+      break;
+
     case GFC_STD_GNU:
       symstd_msg = _("a GNU Fortran extension");
       break;
index d1407186aea1af78e15ccff6f98200fc46ae9bcb..80da011a126caaf48fca23666b3becdcb463b054 100644 (file)
@@ -649,11 +649,8 @@ Degrees function: @*
 @code{ACOSD(X)} computes the arccosine of @var{X} in degrees (inverse of
 @code{COSD(X)}).
 
-This function is for compatibility only and should be avoided in favor of
-standard constructs wherever possible.
-
 @item @emph{Standard}:
-GNU extension, enabled with @option{-fdec-math}
+Fortran 2023
 
 @item @emph{Class}:
 Elemental function
@@ -683,7 +680,7 @@ end program test_acosd
 @item @emph{Specific names}:
 @multitable @columnfractions .20 .23 .20 .33
 @headitem Name            @tab Argument         @tab Return type     @tab Standard
-@item @code{ACOSD(X)}  @tab @code{REAL(4) X} @tab @code{REAL(4)}  @tab GNU extension
+@item @code{ACOSD(X)}  @tab @code{REAL(4) X} @tab @code{REAL(4)}  @tab Fortran 2023
 @item @code{DACOSD(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}  @tab GNU extension
 @end multitable
 
@@ -1369,11 +1366,8 @@ Degrees function: @*
 @code{ASIND(X)} computes the arcsine of its @var{X} in degrees (inverse of
 @code{SIND(X)}).
 
-This function is for compatibility only and should be avoided in favor of
-standard constructs wherever possible.
-
 @item @emph{Standard}:
-GNU extension, enabled with @option{-fdec-math}.
+Fortran 2023
 
 @item @emph{Class}:
 Elemental function
@@ -1403,7 +1397,7 @@ end program test_asind
 @item @emph{Specific names}:
 @multitable @columnfractions .20 .23 .20 .33
 @headitem Name            @tab Argument          @tab Return type       @tab Standard
-@item @code{ASIND(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab GNU extension
+@item @code{ASIND(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 2023
 @item @code{DASIND(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
 @end multitable
 
@@ -1414,8 +1408,6 @@ Radians function: @*
 @ref{ASIN}
 @end table
 
-
-
 @node ASINH
 @section @code{ASINH} --- Inverse hyperbolic sine function
 @fnindex ASINH
@@ -1620,11 +1612,8 @@ Degrees function: @*
 @code{ATAND(X)} computes the arctangent of @var{X} in degrees (inverse of
 @ref{TAND}).
 
-This function is for compatibility only and should be avoided in favor of
-standard constructs wherever possible.
-
 @item @emph{Standard}:
-GNU extension, enabled with @option{-fdec-math}.
+Fortran 2023
 
 @item @emph{Class}:
 Elemental function
@@ -1660,7 +1649,7 @@ end program test_atand
 @item @emph{Specific names}:
 @multitable @columnfractions .23 .23 .20 .30
 @headitem Name            @tab Argument          @tab Return type       @tab Standard
-@item @code{ATAND(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab GNU extension
+@item @code{ATAND(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 2023
 @item @code{DATAND(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
 @end multitable
 
@@ -1752,11 +1741,8 @@ function of the complex number @math{X + i Y} in degrees.  This function can
 be used to transform from Cartesian into polar coordinates and
 allows to determine the angle in the correct quadrant.
 
-This function is for compatibility only and should be avoided in favor of
-standard constructs wherever possible.
-
 @item @emph{Standard}:
-GNU extension, enabled with @option{-fdec-math}.
+Fortran 2023
 
 @item @emph{Class}:
 Elemental function
@@ -1793,7 +1779,7 @@ end program test_atan2d
 @item @emph{Specific names}:
 @multitable @columnfractions .23 .23 .20 .30
 @headitem Name                @tab Argument            @tab Return type    @tab Standard
-@item @code{ATAN2D(X, Y)}  @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab GNU extension
+@item @code{ATAN2D(X, Y)}  @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 2023
 @item @code{DATAN2D(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab GNU extension
 @end multitable
 
@@ -1804,8 +1790,6 @@ Radians function: @*
 @ref{ATAN2}
 @end table
 
-
-
 @node ATANH
 @section @code{ATANH} --- Inverse hyperbolic tangent function
 @fnindex ATANH
@@ -4282,11 +4266,8 @@ Degrees function: @*
 @item @emph{Description}:
 @code{COSD(X)} computes the cosine of @var{X} in degrees.
 
-This function is for compatibility only and should be avoided in favor of
-standard constructs wherever possible.
-
 @item @emph{Standard}:
-GNU extension, enabled with @option{-fdec-math}.
+Fortran 2023
 
 @item @emph{Class}:
 Elemental function
@@ -4316,7 +4297,7 @@ end program test_cosd
 @item @emph{Specific names}:
 @multitable @columnfractions .20 .23 .20 .33
 @headitem Name            @tab Argument            @tab Return type       @tab Standard
-@item @code{COSD(X)}   @tab @code{REAL(4) X}    @tab @code{REAL(4)}    @tab GNU extension
+@item @code{COSD(X)}   @tab @code{REAL(4) X}    @tab @code{REAL(4)}    @tab Fortran 2023
 @item @code{DCOSD(X)}  @tab @code{REAL(8) X}    @tab @code{REAL(8)}    @tab GNU extension
 @item @code{CCOSD(X)}  @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab GNU extension
 @item @code{ZCOSD(X)}  @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
@@ -13298,11 +13279,8 @@ Degrees function: @*
 @item @emph{Description}:
 @code{SIND(X)} computes the sine of @var{X} in degrees.
 
-This function is for compatibility only and should be avoided in favor of
-standard constructs wherever possible.
-
 @item @emph{Standard}:
-GNU extension, enabled with @option{-fdec-math}.
+Fortran 2023
 
 @item @emph{Class}:
 Elemental function
@@ -13330,7 +13308,7 @@ end program test_sind
 @item @emph{Specific names}:
 @multitable @columnfractions .20 .23 .20 .33
 @headitem Name            @tab Argument             @tab Return type       @tab Standard
-@item @code{SIND(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}    @tab GNU extension
+@item @code{SIND(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}    @tab Fortran 2023
 @item @code{DSIND(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}    @tab GNU extension
 @item @code{CSIND(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)} @tab GNU extension
 @item @code{ZSIND(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)} @tab GNU extension
@@ -13344,8 +13322,6 @@ Radians function: @*
 @ref{SIN} @*
 @end table
 
-
-
 @node SINH
 @section @code{SINH} --- Hyperbolic sine function 
 @fnindex SINH
@@ -14147,11 +14123,8 @@ Degrees function: @*
 @item @emph{Description}:
 @code{TAND(X)} computes the tangent of @var{X} in degrees.
 
-This function is for compatibility only and should be avoided in favor of
-standard constructs wherever possible.
-
 @item @emph{Standard}:
-GNU extension, enabled with @option{-fdec-math}.
+Fortran 2023
 
 @item @emph{Class}:
 Elemental function
@@ -14178,7 +14151,7 @@ end program test_tand
 @item @emph{Specific names}:
 @multitable @columnfractions .20 .23 .20 .33
 @headitem Name            @tab Argument          @tab Return type     @tab Standard
-@item @code{TAND(X)}   @tab @code{REAL(4) X}  @tab @code{REAL(4)}  @tab GNU extension
+@item @code{TAND(X)}   @tab @code{REAL(4) X}  @tab @code{REAL(4)}  @tab Fortran 2023
 @item @code{DTAND(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}  @tab GNU extension
 @end multitable