This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Zero extend instead of sign extending pointers in guality tests
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Alexandre Oliva <aoliva at redhat dot com>
- Date: Fri, 12 Feb 2010 11:46:06 +0100
- Subject: [PATCH] Zero extend instead of sign extending pointers in guality tests
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
On 32-bit targets gdb prints pointers as 0xNNNNNNNN, so we certainly
shouldn't sign extend pointers to long long (gualchk_t), but should
zero extend them. This is unrelated to the question/note I've sent
to gcc@ today, as the sign resp. zero extension is explicit in the GUALCVT
macro.
This fixes:
XPASS: gcc.dg/guality/example.c -O0 execution test
+XPASS: gcc.dg/guality/example.c -O1 execution test
+XPASS: gcc.dg/guality/example.c -O2 execution test
XPASS: gcc.dg/guality/example.c -Os execution test
+XPASS: gcc.dg/guality/guality.c -O0 execution test
+XPASS: gcc.dg/guality/guality.c -O1 execution test
+XPASS: gcc.dg/guality/guality.c -O2 execution test
+XPASS: gcc.dg/guality/guality.c -O3 -g execution test
+XPASS: gcc.dg/guality/guality.c -Os execution test
XPASS: gcc.dg/guality/inline-params.c -O0 execution test
XPASS: gcc.dg/guality/inline-params.c -O1 execution test
XPASS: gcc.dg/guality/inline-params.c -O2 execution test
...
on i686-linux. Ok for trunk?
2010-02-12 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/guality/guality.h (GUALCVT): Zero extend instead of
sign extend pointers to gualchk_t.
--- gcc/testsuite/gcc.dg/guality/guality.h.jj 2009-09-29 15:10:38.000000000 +0200
+++ gcc/testsuite/gcc.dg/guality/guality.h 2010-02-12 11:32:01.000000000 +0100
@@ -64,7 +64,11 @@ typedef intmax_t gualchk_t;
#define GUALCVT(val) \
((gualchk_t)__builtin_choose_expr \
(__builtin_types_compatible_p (__typeof (val), gualchk_t), \
- (val), (intptr_t)(val)))
+ (val), \
+ __builtin_choose_expr \
+ (__builtin_classify_type (val) \
+ == __builtin_classify_type (&guality_skip), \
+ (uintptr_t)(val),(intptr_t)(val))))
/* Attach a debugger to the current process and verify that the string
EXPR, evaluated by the debugger, yields the gualchk_t number VAL.
Jakub