re PR fortran/33197 (Fortran 2008: math functions)
2009-07-09 Tobias Burnus <burnus@net-b.de> PR fortran/33197 * check.c (gfc_check_fn_rc2008): New function. * intrinsic.h (gfc_check_fn_rc2008): New prototype. * intrinsic.c (add_functions): Add complex tan, cosh, sinh, and tanh. 2009-07-09 Tobias Burnus <burnus@net-b.de> PR fortran/33197 * gfortran.dg/complex_intrinsic_3.f90: New test. * gfortran.dg/complex_intrinsic_4.f90: New test. From-SVN: r149503
This commit is contained in:
parent
98ac6510fa
commit
8d3681f914
8 changed files with 116 additions and 20 deletions
|
@ -1,3 +1,11 @@
|
|||
2009-07-11 Tobias Burnus <burnus@net-b.de>
|
||||
|
||||
PR fortran/33197
|
||||
* check.c (gfc_check_fn_rc2008): New function.
|
||||
* intrinsic.h (gfc_check_fn_rc2008): New prototype.
|
||||
* intrinsic.c (add_functions): Add complex tan, cosh, sinh,
|
||||
and tanh.
|
||||
|
||||
2009-07-10 Paul Thomas <pault@gcc.gnu.org>
|
||||
|
||||
PR fortran/39334
|
||||
|
|
|
@ -1211,6 +1211,23 @@ gfc_check_fn_rc (gfc_expr *a)
|
|||
}
|
||||
|
||||
|
||||
gfc_try
|
||||
gfc_check_fn_rc2008 (gfc_expr *a)
|
||||
{
|
||||
if (real_or_complex_check (a, 0) == FAILURE)
|
||||
return FAILURE;
|
||||
|
||||
if (a->ts.type == BT_COMPLEX
|
||||
&& gfc_notify_std (GFC_STD_F2008, "Fortran 2008: COMPLEX argument '%s' "
|
||||
"argument of '%s' intrinsic at %L",
|
||||
gfc_current_intrinsic_arg[0], gfc_current_intrinsic,
|
||||
&a->where) == FAILURE)
|
||||
return FAILURE;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
gfc_try
|
||||
gfc_check_fnum (gfc_expr *unit)
|
||||
{
|
||||
|
|
|
@ -1440,7 +1440,7 @@ add_functions (void)
|
|||
make_generic ("cos", GFC_ISYM_COS, GFC_STD_F77);
|
||||
|
||||
add_sym_1 ("cosh", GFC_ISYM_COSH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
|
||||
gfc_check_fn_r, gfc_simplify_cosh, gfc_resolve_cosh,
|
||||
gfc_check_fn_rc2008, gfc_simplify_cosh, gfc_resolve_cosh,
|
||||
x, BT_REAL, dr, REQUIRED);
|
||||
|
||||
add_sym_1 ("dcosh", GFC_ISYM_COSH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
|
||||
|
@ -2405,7 +2405,7 @@ add_functions (void)
|
|||
make_generic ("sin", GFC_ISYM_SIN, GFC_STD_F77);
|
||||
|
||||
add_sym_1 ("sinh", GFC_ISYM_SINH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
|
||||
gfc_check_fn_r, gfc_simplify_sinh, gfc_resolve_sinh,
|
||||
gfc_check_fn_rc2008, gfc_simplify_sinh, gfc_resolve_sinh,
|
||||
x, BT_REAL, dr, REQUIRED);
|
||||
|
||||
add_sym_1 ("dsinh", GFC_ISYM_SINH,CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
|
||||
|
@ -2488,7 +2488,7 @@ add_functions (void)
|
|||
make_generic ("system", GFC_ISYM_SYSTEM, GFC_STD_GNU);
|
||||
|
||||
add_sym_1 ("tan", GFC_ISYM_TAN, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
|
||||
gfc_check_fn_r, gfc_simplify_tan, gfc_resolve_tan,
|
||||
gfc_check_fn_rc2008, gfc_simplify_tan, gfc_resolve_tan,
|
||||
x, BT_REAL, dr, REQUIRED);
|
||||
|
||||
add_sym_1 ("dtan", GFC_ISYM_TAN, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
|
||||
|
@ -2498,7 +2498,7 @@ add_functions (void)
|
|||
make_generic ("tan", GFC_ISYM_TAN, GFC_STD_F77);
|
||||
|
||||
add_sym_1 ("tanh", GFC_ISYM_TANH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F77,
|
||||
gfc_check_fn_r, gfc_simplify_tanh, gfc_resolve_tanh,
|
||||
gfc_check_fn_rc2008, gfc_simplify_tanh, gfc_resolve_tanh,
|
||||
x, BT_REAL, dr, REQUIRED);
|
||||
|
||||
add_sym_1 ("dtanh", GFC_ISYM_TANH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dd, GFC_STD_F77,
|
||||
|
|
|
@ -64,6 +64,7 @@ gfc_try gfc_check_fn_c (gfc_expr *);
|
|||
gfc_try gfc_check_fn_d (gfc_expr *);
|
||||
gfc_try gfc_check_fn_r (gfc_expr *);
|
||||
gfc_try gfc_check_fn_rc (gfc_expr *);
|
||||
gfc_try gfc_check_fn_rc2008 (gfc_expr *);
|
||||
gfc_try gfc_check_fnum (gfc_expr *);
|
||||
gfc_try gfc_check_hostnm (gfc_expr *);
|
||||
gfc_try gfc_check_huge (gfc_expr *);
|
||||
|
|
|
@ -2676,7 +2676,7 @@ Inverse function: @ref{ACOS}
|
|||
@code{COSH(X)} computes the hyperbolic cosine of @var{X}.
|
||||
|
||||
@item @emph{Standard}:
|
||||
Fortran 77 and later
|
||||
Fortran 77 and later, for a complex argument Fortran 2008 or later
|
||||
|
||||
@item @emph{Class}:
|
||||
Elemental function
|
||||
|
@ -2686,14 +2686,14 @@ Elemental function
|
|||
|
||||
@item @emph{Arguments}:
|
||||
@multitable @columnfractions .15 .70
|
||||
@item @var{X} @tab The type shall be @code{REAL}.
|
||||
@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
|
||||
@end multitable
|
||||
|
||||
@item @emph{Return value}:
|
||||
The return value is of type @code{REAL} and it is positive
|
||||
(@math{ \cosh (x) \geq 0 }). For a @code{REAL} argument @var{X},
|
||||
@math{ \cosh (x) \geq 1 }.
|
||||
The return value is of the same kind as @var{X}.
|
||||
The return value has same type and kind as @var{X}. If @var{X} is
|
||||
complex, the imaginary part of the result is in radians. If @var{X}
|
||||
is @code{REAL}, the return value has a lower bound of one,
|
||||
@math{\cosh (x) \geq 1}.
|
||||
|
||||
@item @emph{Example}:
|
||||
@smallexample
|
||||
|
@ -9820,7 +9820,7 @@ end program test_sin
|
|||
@code{SINH(X)} computes the hyperbolic sine of @var{X}.
|
||||
|
||||
@item @emph{Standard}:
|
||||
Fortran 95 and later
|
||||
Fortran 95 and later, for a complex argument Fortran 2008 or later
|
||||
|
||||
@item @emph{Class}:
|
||||
Elemental function
|
||||
|
@ -9830,11 +9830,11 @@ Elemental function
|
|||
|
||||
@item @emph{Arguments}:
|
||||
@multitable @columnfractions .15 .70
|
||||
@item @var{X} @tab The type shall be @code{REAL}.
|
||||
@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
|
||||
@end multitable
|
||||
|
||||
@item @emph{Return value}:
|
||||
The return value is of type @code{REAL}.
|
||||
The return value has same type and kind as @var{X}.
|
||||
|
||||
@item @emph{Example}:
|
||||
@smallexample
|
||||
|
@ -10508,7 +10508,7 @@ END PROGRAM
|
|||
@code{TAN(X)} computes the tangent of @var{X}.
|
||||
|
||||
@item @emph{Standard}:
|
||||
Fortran 77 and later
|
||||
Fortran 77 and later, for a complex argument Fortran 2008 or later
|
||||
|
||||
@item @emph{Class}:
|
||||
Elemental function
|
||||
|
@ -10518,12 +10518,11 @@ Elemental function
|
|||
|
||||
@item @emph{Arguments}:
|
||||
@multitable @columnfractions .15 .70
|
||||
@item @var{X} @tab The type shall be @code{REAL}.
|
||||
@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
|
||||
@end multitable
|
||||
|
||||
@item @emph{Return value}:
|
||||
The return value is of type @code{REAL}. The kind type parameter is
|
||||
the same as @var{X}.
|
||||
The return value has same type and kind as @var{X}.
|
||||
|
||||
@item @emph{Example}:
|
||||
@smallexample
|
||||
|
@ -10558,7 +10557,7 @@ end program test_tan
|
|||
@code{TANH(X)} computes the hyperbolic tangent of @var{X}.
|
||||
|
||||
@item @emph{Standard}:
|
||||
Fortran 77 and later
|
||||
Fortran 77 and later, for a complex argument Fortran 2008 or later
|
||||
|
||||
@item @emph{Class}:
|
||||
Elemental function
|
||||
|
@ -10568,11 +10567,13 @@ Elemental function
|
|||
|
||||
@item @emph{Arguments}:
|
||||
@multitable @columnfractions .15 .70
|
||||
@item @var{X} @tab The type shall be @code{REAL}.
|
||||
@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
|
||||
@end multitable
|
||||
|
||||
@item @emph{Return value}:
|
||||
The return value is of type @code{REAL} and lies in the range
|
||||
The return value has same type and kind as @var{X}. If @var{X} is
|
||||
complex, the imaginary part of the result is in radians. If @var{X}
|
||||
is @code{REAL}, the return value lies in the range
|
||||
@math{ - 1 \leq tanh(x) \leq 1 }.
|
||||
|
||||
@item @emph{Example}:
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2009-07-11 Tobias Burnus <burnus@net-b.de>
|
||||
|
||||
PR fortran/33197
|
||||
* gfortran.dg/complex_intrinsic_3.f90: New test.
|
||||
* gfortran.dg/complex_intrinsic_4.f90: New test.
|
||||
|
||||
2009-07-10 David Daney <ddaney@caviumnetworks.com>
|
||||
|
||||
PR target/39079
|
||||
|
|
39
gcc/testsuite/gfortran.dg/complex_intrinsic_3.f90
Normal file
39
gcc/testsuite/gfortran.dg/complex_intrinsic_3.f90
Normal file
|
@ -0,0 +1,39 @@
|
|||
! { dg-do run }
|
||||
!
|
||||
! PR fortran/33197
|
||||
!
|
||||
! Fortran 2008 complex trigonometric functions: tan, cosh, sinh, tanh
|
||||
!
|
||||
implicit none
|
||||
real(4), parameter :: pi = 2*acos(0.0_4)
|
||||
real(8), parameter :: pi8 = 2*acos(0.0_8)
|
||||
real(4), parameter :: eps = 10*epsilon(0.0_4)
|
||||
real(8), parameter :: eps8 = 10*epsilon(0.0_8)
|
||||
complex(4), volatile :: z0_0 = cmplx(0.0_4, 0.0_4, kind=4)
|
||||
complex(4), volatile :: z1_1 = cmplx(1.0_4, 1.0_4, kind=4)
|
||||
complex(4), volatile :: zp_p = cmplx(pi, pi, kind=4)
|
||||
complex(8), volatile :: z80_0 = cmplx(0.0_8, 0.0_8, kind=8)
|
||||
complex(8), volatile :: z81_1 = cmplx(1.0_8, 1.0_8, kind=8)
|
||||
complex(8), volatile :: z8p_p = cmplx(pi8, pi8, kind=8)
|
||||
|
||||
if (abs(tan(z0_0) - cmplx(0.0,0.0,4)) > eps) call abort()
|
||||
if (abs(tan(z1_1) - cmplx(0.27175257,1.0839232,4)) > eps) call abort()
|
||||
if (abs(tan(z80_0) - cmplx(0.0_8,0.0_8,8)) > eps8) call abort()
|
||||
if (abs(tan(z81_1) - cmplx(0.27175258531951174_8,1.0839233273386946_8,8)) > eps8) call abort()
|
||||
|
||||
if (abs(cosh(z0_0) - cmplx(1.0,0.0,4)) > eps) call abort()
|
||||
if (abs(cosh(z1_1) - cmplx(0.83372992,0.98889768,4)) > eps) call abort()
|
||||
if (abs(cosh(z80_0) - cmplx(1.0_8,0.0_8,8)) > eps8) call abort()
|
||||
if (abs(cosh(z81_1) - cmplx(0.83373002513114913_8,0.98889770576286506_8,8)) > eps8) call abort()
|
||||
|
||||
if (abs(sinh(z0_0) - cmplx(0.0,0.0,4)) > eps) call abort()
|
||||
if (abs(sinh(z1_1) - cmplx(0.63496387,1.2984575,4)) > eps) call abort()
|
||||
if (abs(sinh(z80_0) - cmplx(0.0_8,0.0_8,8)) > eps8) call abort()
|
||||
if (abs(sinh(z81_1) - cmplx(0.63496391478473613_8,1.2984575814159773_8,8)) > eps8) call abort()
|
||||
|
||||
if (abs(tanh(z0_0) - cmplx(0.0,0.0,4)) > eps) call abort()
|
||||
if (abs(tanh(z1_1) - cmplx(1.0839232,0.27175257,4)) > eps) call abort()
|
||||
if (abs(tanh(z80_0) - cmplx(0.0_8,0.0_8,8)) > eps8) call abort()
|
||||
if (abs(tanh(z81_1) - cmplx(1.0839233273386946_8,0.27175258531951174_8,8)) > eps8) call abort()
|
||||
|
||||
end
|
24
gcc/testsuite/gfortran.dg/complex_intrinsic_4.f90
Normal file
24
gcc/testsuite/gfortran.dg/complex_intrinsic_4.f90
Normal file
|
@ -0,0 +1,24 @@
|
|||
! { dg-do compile }
|
||||
! { dg-options "-std=f2003" }
|
||||
!
|
||||
! PR fortran/33197
|
||||
!
|
||||
! Fortran 2008 complex trigonometric functions: tan, cosh, sinh, tanh
|
||||
!
|
||||
real :: r
|
||||
complex :: z
|
||||
r = -45.5
|
||||
r = sin(r)
|
||||
r = cos(r)
|
||||
r = tan(r)
|
||||
r = cosh(r)
|
||||
r = sinh(r)
|
||||
r = tanh(r)
|
||||
z = 4.0
|
||||
z = cos(z)
|
||||
z = sin(z)
|
||||
z = tan(z) ! { dg-error "Fortran 2008: COMPLEX argument" }
|
||||
z = cosh(z)! { dg-error "Fortran 2008: COMPLEX argument" }
|
||||
z = sinh(z)! { dg-error "Fortran 2008: COMPLEX argument" }
|
||||
z = tanh(z)! { dg-error "Fortran 2008: COMPLEX argument" }
|
||||
end
|
Loading…
Add table
Reference in a new issue