diff options
author | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-07-26 17:25:56 +0000 |
---|---|---|
committer | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-07-26 17:25:56 +0000 |
commit | 1b25477b41ad226112d46626a26d189b837d3d83 (patch) | |
tree | b259f058789db8ed3708b7eb713e618b6c81dc13 /gcc/fortran | |
parent | 8cb516d74008a4a95a3d99b5917ba047694f62fb (diff) | |
download | gcc-1b25477b41ad226112d46626a26d189b837d3d83.tar.gz |
2009-07-26 Tobias Burnus <burnus@net-b.de>
PR fortran/33197
* intrinsic.c (make_generic): Remove assert as "atan" can be
both ISYM_ATAN and ISYM_ATAN2.
(add_functions): Add two-argument variant of ATAN.
* intrinsic.h (gfc_check_atan_2): Add check for it.
* intrinsic.texi (ATAN2): Correct and enhance description.
(ATAN): Describe two-argument variant of ATAN.
2009-07-26 Tobias Burnus <burnus@net-b.de>
PR fortran/33197
* gfortran.dg/atan2_1.f90: New test
* gfortran.dg/atan2_2.f90: New test
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150100 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/fortran/check.c | 13 | ||||
-rw-r--r-- | gcc/fortran/intrinsic.c | 7 | ||||
-rw-r--r-- | gcc/fortran/intrinsic.h | 1 | ||||
-rw-r--r-- | gcc/fortran/intrinsic.texi | 18 |
5 files changed, 42 insertions, 7 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 363889f7195..ca320ca8e71 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2009-07-26 Tobias Burnus <burnus@net-b.de> + + PR fortran/33197 + * intrinsic.c (make_generic): Remove assert as "atan" can be + both ISYM_ATAN and ISYM_ATAN2. + (add_functions): Add two-argument variant of ATAN. + * intrinsic.h (gfc_check_atan_2): Add check for it. + * intrinsic.texi (ATAN2): Correct and enhance description. + (ATAN): Describe two-argument variant of ATAN. + 2009-07-25 Tobias Burnus <burnus@net-b.de> Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index e19f8124f09..779af2038e9 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -676,6 +676,19 @@ null_arg: gfc_try +gfc_check_atan_2 (gfc_expr *y, gfc_expr *x) +{ + /* gfc_notify_std would be a wast of time as the return value + is seemingly used only for the generic resolution. The error + will be: Too many arguments. */ + if ((gfc_option.allow_std & GFC_STD_F2008) == 0) + return FAILURE; + + return gfc_check_atan2 (y, x); +} + + +gfc_try gfc_check_atan2 (gfc_expr *y, gfc_expr *x) { if (type_check (y, 0, BT_REAL) == FAILURE) diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index 0b2d1b8c8db..d2cdb591888 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -1008,8 +1008,6 @@ make_generic (const char *name, gfc_isym_id id, int standard ATTRIBUTE_UNUSED) while (g->name != NULL) { - gcc_assert (g->id == id); - g->next = g + 1; g->specific = 1; g++; @@ -1250,6 +1248,11 @@ add_functions (void) gfc_check_fn_d, gfc_simplify_atan, gfc_resolve_atan, x, BT_REAL, dd, REQUIRED); + /* Two-argument version of atan, equivalent to atan2. */ + add_sym_2 ("atan", GFC_ISYM_ATAN2, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, GFC_STD_F2008, + gfc_check_atan_2, gfc_simplify_atan2, gfc_resolve_atan2, + y, BT_REAL, dr, REQUIRED, x, BT_REAL, dr, REQUIRED); + make_generic ("atan", GFC_ISYM_ATAN, GFC_STD_F77); add_sym_1 ("atanh", GFC_ISYM_ATANH, CLASS_ELEMENTAL, ACTUAL_YES, BT_REAL, dr, diff --git a/gcc/fortran/intrinsic.h b/gcc/fortran/intrinsic.h index 1e2fbd7a027..a239ad6d35b 100644 --- a/gcc/fortran/intrinsic.h +++ b/gcc/fortran/intrinsic.h @@ -37,6 +37,7 @@ gfc_try gfc_check_achar (gfc_expr *, gfc_expr *); gfc_try gfc_check_all_any (gfc_expr *, gfc_expr *); gfc_try gfc_check_allocated (gfc_expr *); gfc_try gfc_check_associated (gfc_expr *, gfc_expr *); +gfc_try gfc_check_atan_2 (gfc_expr *, gfc_expr *); gfc_try gfc_check_atan2 (gfc_expr *, gfc_expr *); gfc_try gfc_check_besn (gfc_expr *, gfc_expr *); gfc_try gfc_check_btest (gfc_expr *, gfc_expr *); diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi index 2e6908f705b..2c993b9048a 100644 --- a/gcc/fortran/intrinsic.texi +++ b/gcc/fortran/intrinsic.texi @@ -1353,22 +1353,28 @@ end program test_associated @code{ATAN(X)} computes the arctangent of @var{X}. @item @emph{Standard}: -Fortran 77 and later, for a complex argument Fortran 2008 or later +Fortran 77 and later, for a complex argument and for two arguments +Fortran 2008 or later @item @emph{Class}: Elemental function @item @emph{Syntax}: @code{RESULT = ATAN(X)} +@code{RESULT = ATAN(Y, X)} @item @emph{Arguments}: @multitable @columnfractions .15 .70 -@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}. +@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}; +if @var{Y} is present, @var{X} shall be REAL. +@item @var{Y} shall be of the same type and kind as @var{X}. @end multitable @item @emph{Return value}: The return value is of the same type and kind as @var{X}. -The real part of the result is in radians and lies in the range +If @var{Y} is present, the result is identical to @code{ATAN2(Y,X)}. +Otherwise, it the arcus tangent of @var{X}, where the real part of +the result is in radians and lies in the range @math{-\pi/2 \leq \Re \atan(x) \leq \pi/2}. @item @emph{Example}: @@ -1401,8 +1407,10 @@ Inverse function: @ref{TAN} @table @asis @item @emph{Description}: -@code{ATAN2(Y, X)} computes the arctangent of the complex number -@math{X + i Y}. +@code{ATAN2(Y, X)} computes the principal value of the argument +function of the complex number @math{X + i Y}. This function can +be used to transform from carthesian into polar coordinates and +allows to determine the angle in the correct quadrant. @item @emph{Standard}: Fortran 77 and later |