Re: [PATCH, Fortran] Correct declaration of frexp and friends
Hi Tobias, Pong. It helps to send Fortran patches also to fortran@ ... indeed :) On 30/03/11 16:43, Duncan Sands wrote: While working on the dragonegg plugin I noticed that the Fortran front-end declares frexp with the parameters the wrong way round. Instead of double frexp(double x, int *exp); it is declared as double frexp(int *exp, double x); OK to apply on mainline and the 4.5 and 4.6 branches? OK and thanks for the patch. Do you have an GCC SVN account? I do, so that's not a problem. By the way I just noticed that the arguments to the scalbn functions also seem to be the wrong way round: gfc_define_builtin (__builtin_scalbnl, mfunc_longdouble[5], BUILT_IN_SCALBNL, scalbnl, ATTR_CONST_NOTHROW_LEAF_LIST); gfc_define_builtin (__builtin_scalbn, mfunc_double[5], BUILT_IN_SCALBN, scalbn, ATTR_CONST_NOTHROW_LEAF_LIST); gfc_define_builtin (__builtin_scalbnf, mfunc_float[5], BUILT_IN_SCALBNF, scalbnf, ATTR_CONST_NOTHROW_LEAF_LIST); but /* type (*) (int, type) */ fntype[5] = build_function_type_list (type, integer_type_node, type, NULL_TREE); so it looks like you get scalbn(int, double) and not scalbn(double, int) etc. If you agree that they are the wrong way round I will fix this too. Ciao, Duncan. Tobias 2011-03-30 Duncan Sands baldr...@free.fr * f95-lang.c (build_builtin_fntypes): Swap frexp parameter types. - /* type (*) (int, type) */ - fntype[4] = build_function_type_list (type, + /* type (*) (type, int) */ + fntype[4] = build_function_type_list (type, type, build_pointer_type (integer_type_node), - type, NULL_TREE);
Re: [PATCH, Fortran] Correct declaration of frexp and friends
Hi Ducan, On 04/05/2011 11:41 AM, Duncan Sands wrote: By the way I just noticed that the arguments to the scalbn functions also seem to be the wrong way round: here's a gcc-4.5 patch which fixes: (1) the comment for fntype[2], (2) the prototypes for the frexp family and (3) the prototypes for the scalbn family. I checked all uses of all of the function types declared here and all the rest seem to be correct. I also took a look at an example using scalbn and it looks like calls to scalbn pass arguments in the right order (i.e. consistent with the fixed prototype). I'm running the testsuite now. OK to apply to the 4.5 branch if it passes testing? OK. (Contrary to the now fixed frexp, it seems to only affect 4.6.) Thanks for checking and fixing these bugs! Tobias Index: f95-lang.c === --- f95-lang.c(revision 171972) +++ f95-lang.c(working copy) @@ -646,19 +646,20 @@ /* type (*) (type, type) */ tmp = tree_cons (NULL_TREE, type, tmp); fntype[1] = build_function_type (type, tmp); - /* type (*) (int, type) */ + /* type (*) (type, int) */ tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node); tmp = tree_cons (NULL_TREE, type, tmp); fntype[2] = build_function_type (type, tmp); /* type (*) (void) */ fntype[3] = build_function_type (type, void_list_node); /* type (*) (type, int) */ - tmp = tree_cons (NULL_TREE, type, void_list_node); - tmp = tree_cons (NULL_TREE, build_pointer_type (integer_type_node), tmp); + tmp = tree_cons (NULL_TREE, build_pointer_type (integer_type_node), + void_list_node); + tmp = tree_cons (NULL_TREE, type, tmp); fntype[4] = build_function_type (type, tmp); /* type (*) (type, int) */ - tmp = tree_cons (NULL_TREE, type, void_list_node); - tmp = tree_cons (NULL_TREE, integer_type_node, tmp); + tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node); + tmp = tree_cons (NULL_TREE, type, tmp); fntype[5] = build_function_type (type, tmp); }
[PATCH, Fortran] Correct declaration of frexp and friends
While working on the dragonegg plugin I noticed that the Fortran front-end declares frexp with the parameters the wrong way round. Instead of double frexp(double x, int *exp); it is declared as double frexp(int *exp, double x); This is fairly harmless but might as well be fixed, so here is a patch (as far as I can see fntype[4] is only used in declaring the frexp family of functions). Bootstraps and has no impact on the Fortran testsuite (tested on mainline). OK to apply on mainline and the 4.5 and 4.6 branches? Proposed fortran/Changelog entry: 2011-03-30 Duncan Sands baldr...@free.fr * f95-lang.c (build_builtin_fntypes): Swap frexp parameter types. Index: gcc/fortran/f95-lang.c === --- gcc/fortran/f95-lang.c (revision 171716) +++ gcc/fortran/f95-lang.c (working copy) @@ -695,10 +695,9 @@ type, integer_type_node, NULL_TREE); /* type (*) (void) */ fntype[3] = build_function_type_list (type, NULL_TREE); - /* type (*) (int, type) */ - fntype[4] = build_function_type_list (type, + /* type (*) (type, int) */ + fntype[4] = build_function_type_list (type, type, build_pointer_type (integer_type_node), -type, NULL_TREE); /* type (*) (int, type) */ fntype[5] = build_function_type_list (type,