This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
The following patch should fix the failure of gcc.dg/ftrapv-2.c on s390x-ibm-linux as reported by Ulrich Weigand. The problem is that calls to unprototyped builtin functions don't have their arguments promoted to their assumed types. In the case of ftrapv-2.c, we were calling "abs" with a long argument, and without a function prototype the front-end doesn't attempt to cast the long to an "int". The mistake is then in the middle-end, where fold_builtin_abs checks that the single argument has integer type, but neither checks nor coerces it to the required width. Fortunately, this mistake is tolerated by the poor typing in the RTL expanders, but using -ftrapv is enough to expose the problem. The following patch has been tested on i686-pc-linux-gnu with a full "make bootstrap", all default languages, and regression tested with a top-level "make -k check" with no new failures. I've also confirmed that this resolves the ftrapv-2.c ICE in a cross-compiler cc1 to s390x-ibm-linux. Committed to mainline CVS. 2005-01-11 Roger Sayle <roger@eyesopen.com> * builtins.c (fold_builtin_fabs): Convert argument to the appropriate type as args of unprototyped builtins aren't automatically promoted. (fold_builtin_abs): Likewise. Index: builtins.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/builtins.c,v retrieving revision 1.411 diff -c -3 -p -r1.411 builtins.c *** builtins.c 7 Jan 2005 09:00:50 -0000 1.411 --- builtins.c 12 Jan 2005 02:56:34 -0000 *************** fold_builtin_fabs (tree arglist, tree ty *** 7449,7454 **** --- 7449,7455 ---- return 0; arg = TREE_VALUE (arglist); + arg = fold_convert (type, arg); if (TREE_CODE (arg) == REAL_CST) return fold_abs_const (arg, type); return fold (build1 (ABS_EXPR, type, arg)); *************** fold_builtin_abs (tree arglist, tree typ *** 7465,7470 **** --- 7466,7472 ---- return 0; arg = TREE_VALUE (arglist); + arg = fold_convert (type, arg); if (TREE_CODE (arg) == INTEGER_CST) return fold_abs_const (arg, type); return fold (build1 (ABS_EXPR, type, arg)); Roger --
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |