Ignore this patch as I think I have a better way to fix it.
-----Original Message-----
From: Gibbs Tanton - tgibbs
To: '[EMAIL PROTECTED] '
Sent: 9/18/2001 9:44 AM
Subject: [PATCH]pedantic
This patch allows parrot to compile cleanly under the -pedantic flag of
gcc.
It removes the lvalue casts in GRAB_IV and DO_OP. GRAB_IV I had to add
a
variable that was an IV** to hold the program code in each function that
used GRAB_IV. With DO_OP I just changed the lvalue cast to an rvalue
cast.
Let me know of any improvements I could make.
Index: build_interp_starter.pl
===================================================================
RCS file: /home/perlcvs/parrot/build_interp_starter.pl,v
retrieving revision 1.9
diff -u -u -r1.9 build_interp_starter.pl
--- build_interp_starter.pl 2001/09/18 01:20:43 1.9
+++ build_interp_starter.pl 2001/09/18 14:38:59
@@ -62,7 +62,7 @@
#define DO_OP(w,x,y,z) do { \\
x = (void *)z->opcode_funcs; \\
- (void *)y = x[*w]; \\
+ y = (IV* (*)())x[*w]; \\
w = (y)(w,z); \\
} while (0);
EOI
Index: bytecode.c
===================================================================
RCS file: /home/perlcvs/parrot/bytecode.c,v
retrieving revision 1.10
diff -u -u -r1.10 bytecode.c
--- bytecode.c 2001/09/17 17:38:14 1.10
+++ bytecode.c 2001/09/18 14:39:00
@@ -31,7 +31,7 @@
#include "parrot/parrot.h"
-#define GRAB_IV(x) *((IV*)*x)++
+#define GRAB_IV(x) *(*x)++
/*
@@ -51,8 +51,9 @@
static int
check_magic(void** program_code, long* program_size) {
+ IV** pcode = (IV**)program_code;
program_size -= sizeof(IV);
- return (GRAB_IV(program_code) == PARROT_MAGIC);
+ return (GRAB_IV(pcode) == PARROT_MAGIC);
}
/*
@@ -74,7 +75,8 @@
static void
read_constants_table(void** program_code, long* program_size)
{
- IV len = GRAB_IV(program_code);
+ IV ** pcode = (IV**)program_code;
+ IV len = GRAB_IV(pcode);
IV num;
IV i = 0;
@@ -85,24 +87,24 @@
return;
}
- num = GRAB_IV(program_code);
+ num = GRAB_IV(pcode);
len -= sizeof(IV);
*program_size -= sizeof(IV);
Parrot_string_constants = mem_allocate_aligned(num *
sizeof(STRING*));
while (len > 0) {
- IV flags = GRAB_IV(program_code);
- IV encoding = GRAB_IV(program_code);
- IV type = GRAB_IV(program_code);
- IV buflen = GRAB_IV(program_code);
+ IV flags = GRAB_IV(pcode);
+ IV encoding = GRAB_IV(pcode);
+ IV type = GRAB_IV(pcode);
+ IV buflen = GRAB_IV(pcode);
int pad;
len -= 4 * sizeof(IV);
*program_size -= 4 * sizeof(IV);
- Parrot_string_constants[i++] = string_make(*program_code /*
ouch
*/, buflen, encoding, flags, type);
- (char*)*program_code += buflen;
+ Parrot_string_constants[i++] = string_make((char*)*pcode /*
ouch
*/, buflen, encoding, flags, type);
+ *pcode = (IV*)((char*)*pcode + buflen);
len -= buflen;
*program_size -= buflen;
@@ -111,7 +113,7 @@
if (pad) {
pad=sizeof(IV)-pad;
len -= pad;
- (char*)*program_code += pad;
+ *pcode = (IV*)((char*)*pcode + pad);
*program_size -= pad;
}
num--;
@@ -140,10 +142,11 @@
static void
read_fixup_table(void** program_code, long* program_size)
{
- IV len = GRAB_IV(program_code);
+ IV** pcode = (IV**)program_code;
+ IV len = GRAB_IV(pcode);
*program_size -= sizeof(IV);
/* For now, just skip over it */
- ((IV*)*program_code) += len;
+ *pcode += len;
*program_size -= len;
}