All, Attached is a patch extending the GNU Fortran front-end to support some additional math intrinsics, enabled with a new compile flag -fdec-math. The flag adds the COTAN intrinsic (cotangent), as well as degree versions of all trigonometric intrinsics (SIND, TAND, ACOSD, etc...). This extension allows for further compatibility with legacy code that depends on the compiler to support such intrinsic functions. I would definitely like some peer review on this patch to ensure my implementation has no unintended mathematical side-effects, such as rounding errors, or oversights with complex math: I implement the degree-valued functions by simply converting the argument or result to degrees/radians as appropriate by multiplying by the factor pi/180 (or 180/pi). In the constant case this is done using mpfr/mpc, and in the non-constant case the factor multiplication expression is just inserted into the expression tree where appropriate. The new COTAN intrinsic is implemented using mpfr_cot in the constant case, and by replacing the call with a 1/tan expression in the non-constant case (and in the complex case, since there is no mpc_cot). See the new functions in simplify.c/iresolve.c for specifics. I also added a new macro MATH_ALIAS_BUILTIN used in mathbuiltins.def to define the new COTAN intrinsic. This macro defines a new isym, but keeps everything else defined normally by DEFINE_MATH_BUILTIN the same as an existing isym (TAN in this case). The reason for this is to avoid having to define a new BUILT_IN_COTAN in gcc/builtins.def (or any other context). As I described above, the simplify/resolve code for COTAN just wraps TAN. I am not 100% convinced this is the "right" or "best" way to do this - so feel free to me know if there are any problems with this approach. By the way, I don't use intrinsic.c (make_alias) for these because they need their own simplification/resolution routines to handle the degree-radian conversion. As usual the patched compiler bootstraps and regtests on x86_64-redhat-linux. Questions, comments and concerns are very welcome. Barring any, is this OK for trunk? --- Fritz Reese 2016-09-26 Fritz Reese New flag -fdec-math for COTAN and degree trig intrinsics. gcc/fortran/ * lang.opt: New flag -fdec-math. * options.c (set_dec_flags): Enable with -fdec. * invoke.texi, gfortran.texi, intrinsic.texi: Update documentation. * trans-intrinsic.c (MATH_ALIAS_BUILTLIN): New macro for math aliases. * f95-lang.c (MATH_ALIAS_BUILTIN): New macro for math aliases. * mathbuiltins.def (MATH_ALIAS_BUILTIN): Use for cotan. * intrinsics.c (add_functions, do_simplify): New intrinsics with -fdec-math. * gfortran.h (gfc_isym_id): New isym GFC_ISYM_COTAN. * gfortran.h (gfc_resolve_atan2d, gfc_resolve_cotan, gfc_resolve_trigd, gfc_resolve_atrigd): New prototypes. * iresolve.c (resolve_trig_call, get_degrees, get_radians, is_trig_resolved, gfc_resolve_cotan, gfc_resolve_trigd, gfc_resolve_atrigd, gfc_resolve_atan2d): New functions. * intrinsics.h (gfc_simplify_atan2d, gfc_simplify_atrigd, gfc_simplify_cotan, gfc_simplify_trigd): New prototypes. * simplify.c (simplify_trig_call, degrees_f, radians_f, gfc_simplify_cotan, gfc_simplify_trigd, gfc_simplify_atrigd, gfc_simplify_atan2d): New functions. gcc/testsuite/gfortran.dg/ * dec_math.f90: New testsuite.