This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix type-mismatch in mips_gimplify_va_arg_expr
- From: Adam Nemet <anemet at caviumnetworks dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 19 Nov 2008 14:47:54 -0800
- Subject: [PATCH] Fix type-mismatch in mips_gimplify_va_arg_expr
The testcase below fails type-checking with EABI32 as the type of OFF is
unsigned char and the default type, build_int_cst uses is int. This happens
while building newlib in the combined tree.
Since the type is unsigned char and the amount is always < UNITS_PER_WORD,
it's safe to directly build the constant with type unsigned char.
Tested with mipsisa64r2-elf with {,-mips32r2} and with type checking. I
compared the results to a clean build without type checking (release).
OK to install?
Adam
* config/mips/mips.c (mips_gimplify_va_arg_expr): Use -rsize
with the same type as the first operand of the AND expression.
testsuite/
* gcc.c-torture/compile/20081119-1.c: New test.
Index: config/mips/mips.c
===================================================================
--- config/mips/mips.c (revision 141996)
+++ config/mips/mips.c (working copy)
@@ -5332,7 +5332,7 @@ mips_gimplify_va_arg_expr (tree valist,
{
/* [1] Emit code for: off &= -rsize. */
t = build2 (BIT_AND_EXPR, TREE_TYPE (off), off,
- build_int_cst (NULL_TREE, -rsize));
+ build_int_cst (TREE_TYPE (off), -rsize));
gimplify_assign (off, t, pre_p);
}
osize = rsize;
Index: testsuite/gcc.c-torture/compile/20081119-1.c
===================================================================
--- testsuite/gcc.c-torture/compile/20081119-1.c (revision 0)
+++ testsuite/gcc.c-torture/compile/20081119-1.c (revision 0)
@@ -0,0 +1,5 @@
+unsigned long long
+f (__builtin_va_list ap)
+{
+ return __builtin_va_arg (ap, unsigned long long);
+}