This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[RFA]: Fix tests 980223.c and 20010327-1.c (was is 980223.c wrong?)
- To: Aldy Hernandez <aldyh at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Subject: [RFA]: Fix tests 980223.c and 20010327-1.c (was is 980223.c wrong?)
- From: Stephane Carrez <Stephane dot Carrez at worldnet dot fr>
- Date: Fri, 14 Sep 2001 22:07:17 +0200
- CC: gcc at gcc dot gnu dot org
Hi!
Aldy Hernandez <aldyh@redhat.com> wrote:
>
> i'm having doubts about 980223.c:
>
> int nil;
> object cons1[2] = { {(long) &nil, 0}, {(long) &nil, 0} };
> object cons2[2] = { {(long) &cons1, 64}, {(long) &nil, 0} };
>
> if sizeof(long) != sizeof(int *), the initializer is not a constant and
> gcc barfs.
>
> particularly this gives problem with mips when longs are 64bits and GP
> registers (and consecuently pointers) are 32bits.
I have the same problem with 68HC11/HC12 where pointers are 16-bits while
long is 32 bits. There is the same problem with compile/20010327-1.c.
Instead of using 'long' for the cast, we can use __SIZE_TYPE__
(as suggested to me by Richard in June).
Can someone approve this patch ?
Thanks,
Stephane
2001-09-14 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* gcc.c-torture/compile/20010327-1.c: Use __SIZE_TYPE__ instead
of unsigned long.
* gcc.c-torture/execute/980223.c: Likewise.
Index: gcc.c-torture/compile/20010327-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.c-torture/compile/20010327-1.c,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 20010327-1.c
--- 20010327-1.c 2001/03/27 06:17:30 1.1.2.1
+++ 20010327-1.c 2001/09/14 20:00:58
@@ -1,2 +1,2 @@
extern void _text;
-static unsigned long x = (unsigned long) &_text - 0x10000000L - 1;
+static __SIZE_TYPE__ x = (__SIZE_TYPE__) &_text - 0x10000000L - 1;
Index: gcc.c-torture/execute/980223.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.c-torture/execute/980223.c,v
retrieving revision 1.2
diff -u -p -r1.2 980223.c
--- 980223.c 1998/12/16 22:14:39 1.2
+++ 980223.c 2001/09/14 20:00:58
@@ -1,4 +1,4 @@
-typedef struct { long addr; long type; } object;
+typedef struct { __SIZE_TYPE__ addr; long type; } object;
object bar (object blah)
{
@@ -19,8 +19,8 @@ object foo (object x, object y)
}
int nil;
-object cons1[2] = { {(long) &nil, 0}, {(long) &nil, 0} };
-object cons2[2] = { {(long) &cons1, 64}, {(long) &nil, 0} };
+object cons1[2] = { {(__SIZE_TYPE__) &nil, 0}, {(__SIZE_TYPE__) &nil, 0} };
+object cons2[2] = { {(__SIZE_TYPE__) &cons1, 64}, {(__SIZE_TYPE__) &nil, 0} };
main()
{