changeset 467:32737bad7489

fix list/tag interference
author kono
date Sat, 30 Jul 2005 16:01:45 +0900
parents 7c3d8237b625
children 464e7480395c
files .gdbinit Changes Makefile mc-code-powerpc.c mc-codegen.c mc-parse.c mc.h test/basic.c test/bitfield.c test/bitfield1.c test/call.c test/cext.c test/const.c test/enum.c test/long.c test/macro.c test/obsf2.c test/regargs.c test/short.c test/simp0.c test/simp1.c test/static.c test/strinit.c test/switch.c test/tmp.c test/tmp11.c test/tmp12.c test/tmp7.c test/tmp8.c test/void_code.c
diffstat 30 files changed, 91 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/.gdbinit	Mon May 16 11:53:56 2005 +0900
+++ b/.gdbinit	Sat Jul 30 16:01:45 2005 +0900
@@ -1,15 +1,3 @@
-tb main
-# run  -s test/inline.c
-# run  -s mc-parse.c
-# run  -s mc-codegen.c
-# run  -s nkf203/nkf.c
-# run  -s -ob01.s mc-switch.c
-# run  -s l.c
-# run  -s test/const.c
-# run  -s test/basic.c
-# run -s test/code-gen-all.c
-# run -s test/tmp7.c
-run -s test/inline.c
 define regs 
 printf "pc =%08x lr =%08x r0 =%08x r1 =%08x r3= %08x r4= %08x\n",$pc,$lr,$r0,$r1,$r3,$r4
 printf "r10=%08x r11=%08x r12=%08x r13=%08x r14=%08x r15=%08x\n",$r10,$r11,$r12,$r13,$r14,$r15
@@ -42,3 +30,15 @@
 x/1i $pc
 end
 b errmsg
+tb main
+# run  -s test/inline.c
+run  -s mc-parse.c
+# run  -s mc-codegen.c
+# run  -s nkf203/nkf.c
+# run  -s -ob01.s mc-switch.c
+# run  -s l.c
+# run  -s test/const.c
+# run  -s test/basic.c
+# run -s test/code-gen-all.c
+# run -s test/tmp7.c
+# run -s test/inline.c
--- a/Changes	Mon May 16 11:53:56 2005 +0900
+++ b/Changes	Sat Jul 30 16:01:45 2005 +0900
@@ -7163,10 +7163,10 @@
 
 これは.... memcpy なのか。
 
-
-
-
-
-
-
-
+Sat Jul 30 14:41:54 JST 2005
+
+あぁ、function の型のlist node にVOIDというprimitive型が入ってしまって
+いるね。これは、なんか、やっちまった記憶があるが...
+
+inline code ってのはありえるの?
+
--- a/Makefile	Mon May 16 11:53:56 2005 +0900
+++ b/Makefile	Sat Jul 30 16:01:45 2005 +0900
@@ -1,4 +1,4 @@
-CC = gcc
+CC = gcc -std=c99
 # -O3
 CFLAGS = -g -Wall -I.
 # CFLAGS = -g -Wall -I. -pg -fprofile-arcs -ftest-coverage
--- a/mc-code-powerpc.c	Mon May 16 11:53:56 2005 +0900
+++ b/mc-code-powerpc.c	Sat Jul 30 16:01:45 2005 +0900
@@ -146,12 +146,12 @@
 
 #define DEBUG_REG 1
 #if DEBUG_REG
-char *rn(i) { return register_name(i); }
-char *fn(i) { return fregister_name(i); }
-char *lln(i) { return lregister_name_low(i); }
-char *lhn(i) { return lregister_name_high(i); }
-int ll(i) { return regv_l(i); }
-int lh(i) { return regv_h(i); }
+char *rn(int i) { return register_name(i); }
+char *fn(int i) { return fregister_name(i); }
+char *lln(int i) { return lregister_name_low(i); }
+char *lhn(int i) { return lregister_name_high(i); }
+int ll(int i) { return regv_l(i); }
+int lh(int i) { return regv_h(i); }
 #endif
 
 #define is_int_reg(i)  (0<=i&&i<REAL_MAX_REGISTER)
@@ -902,7 +902,7 @@
 #endif
 #define USAGE_MAX 4
     if (!lsrc) return;
-    printf("# %d: %s:",lineno,s);
+    printf("## %d: %s:",lineno,s);
     if (ireg) printf(" creg=%s",register_name(ireg));
     if (freg) printf(" freg=%s",fregister_name(freg));
     if (lreg) printf(" lreg=%s,%s",lregister_name_high(lreg),
@@ -5373,7 +5373,7 @@
     int size;
     set_bitsz(type,&bitpos,&bitsize,&sign,&bitsz,&align,&l);
     size = bitsz/8;
-// printf("# %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz);
+// printf("## %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz);
     if (l) {
 #if LONGLONG_CODE
 	// use_int(adr);
@@ -5469,7 +5469,7 @@
     char *crn;
     set_bitsz(type,&bitpos,&bitsize,&sign,&bitsz,&align,&l);
     size = bitsz/8;
-// printf("# %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz);
+// printf("## %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz);
     if (l) {
 #if LONGLONG_CODE
 	use_int(adr);
--- a/mc-codegen.c	Mon May 16 11:53:56 2005 +0900
+++ b/mc-codegen.c	Sat Jul 30 16:01:45 2005 +0900
@@ -2686,7 +2686,7 @@
         /* Struct fields name lists are in the struct type or tag. */
         /* Only name in the table is used. Do not set n->ty! */
 	/* Struct field may volatile... where do I put? list2(VOLATILE,type)? */
-	if (car(type)==BIT_FIELD) {
+	if (type>0 && car(type)==BIT_FIELD) {
 	    bit_field_disp=sbit_f;   // default is 0, recover only here.
             //        type = list4(BIT_FIELD,value type,
             //            list3(store type,bit offset,bit_width));
@@ -2703,7 +2703,7 @@
 	if (n!=&null_nptr)
 	    fields = list4(type,fields,(int)(n->nm),disp);
     } else if (mode==GUDECL||mode==LUDECL) {
-	if (car(type)==BIT_FIELD) {
+	if (type>0 && car(type)==BIT_FIELD) {
 	    cadr(caddr(type)) = 0; sz = size(cadr(type));
 	}  else {
 	    sz = size(type);
@@ -2767,7 +2767,7 @@
 	    ndsp = fwdlabel();
 	break;
     case ADECL:
-	if(!integral(type)&&(car(type)==FUNCTION||car(type)==CODE)) {
+	if(!integral(type)&&type>0&&(car(type)==FUNCTION||car(type)==CODE)) {
 	    type=list2(POINTER,type); n->ty = type;
 	}
 	fnptr->dsp=list4(type,fnptr->dsp,(int)n,0);
@@ -3120,7 +3120,9 @@
     if(integral(t1)) {
 	    if(t1!=t2) error(TYERR);
     }
-    else if(car(t1)!=car(t2))
+    else if(t1<0 || t2<0) {
+	if(t1!=t2) error(TYERR);
+    } else if(car(t1)!=car(t2))
 	    error(TYERR);
     else if((car(t1)==STRUCT || car(t1)==UNION) && cadr(t1)!=cadr(t2))
 	    error(TYERR);
@@ -3131,7 +3133,7 @@
 extern int
 scalar(int t)
 {
-    return(integral(t)||car(t)==POINTER);
+    return(integral(t)||(t>0 && car(t)==POINTER));
 }
 
 extern int
--- a/mc-parse.c	Mon May 16 11:53:56 2005 +0900
+++ b/mc-parse.c	Sat Jul 30 16:01:45 2005 +0900
@@ -3110,10 +3110,14 @@
 {
     int e1;
     e1=list2(FNAME,(int)nptr);
-    // type=list3(FUNCTION,type,arg);
-    type=list3(car(nptr->ty),cadr(nptr->ty),caddr(nptr->ty));
+    if (nptr->ty>0) { // should be function or code
+	// type=list3(FUNCTION,type,arg);
+	type=list3(car(nptr->ty),cadr(nptr->ty),caddr(nptr->ty));
+    } else { // label
+	type=nptr->ty;
+    }
     getsym(0);
-    extrn_use(nptr);
+    // extrn_use(nptr);  can be static
     return expr16(e1);
 }
 
@@ -3358,13 +3362,13 @@
 
     /* function call target */
 
-    if(car(type)==POINTER) {
+    if(type>0 && car(type)==POINTER) {
 	if (car(cadr(type))==FUNCTION||car(cadr(type))==CODE) {
 	    e1=rvalue(e1);
 	    type=cadr(type);
 	} /* else error */
     }
-    if(integral(type)|| ((car(type)!=FUNCTION)&&(car(type)!=CODE))) {
+    if(integral(type)||type<0|| ((car(type)!=FUNCTION)&&(car(type)!=CODE))) {
 	error(TYERR);
     }
     ftype = type;
@@ -3393,7 +3397,7 @@
     }
     checksym(RPAR);
     conv->funcall_args_();
-    if(car(t)==CODE)
+    if(t<0 && t==CODE)
 	return list4(FUNCTION,e1,arglist,ftype);
 
     /* return type */
@@ -3401,7 +3405,7 @@
     type = cadr(ftype); 
     if(type==CHAR||type==SHORT) type=INT;
     else if(type==UCHAR||type==USHORT) type=UNSIGNED;
-    else if(car(type)==STRUCT||car(type)==UNION) {
+    else if(type>0 && (car(type)==STRUCT||car(type)==UNION)) {
 	/* make temporary struct for return value */
 	/* but it is better to see we can reuse old one */
 	if (tmp_struct) {
@@ -3645,7 +3649,7 @@
     /* no name copy */
     unsigned int ch,i = 0;
     unsigned int hash0 = 0;
-    unsigned char *n = name;
+    char *n = name;
     struct cheap scheap;
 
     save_cheap(&scheap,cheap);
@@ -4057,7 +4061,8 @@
 	    nptr_pool = nptr_pool->next;
 	}
     }
-    ret = ((NMTBL *)nptr_pool->ptr)++;
+    ret = (NMTBL *)nptr_pool->ptr;
+    nptr_pool->ptr += sizeof(NMTBL);
     ret->sc = 0;
     ret->ty = 0;
     ret->dsp = 0;
--- a/mc.h	Mon May 16 11:53:56 2005 +0900
+++ b/mc.h	Sat Jul 30 16:01:45 2005 +0900
@@ -493,9 +493,9 @@
 extern void free_nptr(NMTBL *n);
 extern NMTBL *get_nptr();
 
-#if 0
+#if 1
 extern int heapsize;
-#define CHECK_HEAP(b) ({int _k=(int)(b);if(_k>heapsize)error(-1);_k;})
+#define CHECK_HEAP(b) ({int _k=(int)(b);if(_k>heapsize||_k<0)error(-1);_k;})
 #else
 #define CHECK_HEAP(b)  (b)
 #endif
--- a/test/basic.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/basic.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,6 @@
+int printf(const char *format, ...);
+
+
 #define ARG_ADDRESS 0
 
 double ggg = 0.134;
--- a/test/bitfield.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/bitfield.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,4 @@
+int printf(const char *format, ...);
 
 
 typedef union {
--- a/test/bitfield1.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/bitfield1.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,4 @@
+int printf(const char *format, ...);
 
    struct aho {
         int i:1,j:1;
--- a/test/call.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/call.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,5 @@
+int printf(const char *format, ...);
+
 
 int
 a0(int i);
--- a/test/cext.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/cext.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,4 @@
+int printf(const char *format, ...);
 
 unsigned int u;
 
--- a/test/const.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/const.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,5 @@
+int printf(const char *format, ...);
+
 main()
 {
     int i;
--- a/test/enum.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/enum.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,4 @@
+int printf(const char *format, ...);
 
 enum {
     a,b,c
--- a/test/long.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/long.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,5 @@
+int printf(const char *format, ...);
+
 
 long long gj;
 long long gi;
--- a/test/macro.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/macro.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,5 @@
+int printf(const char *format, ...);
+
 
 int heap[100];
 
--- a/test/obsf2.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/obsf2.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,5 @@
+int printf(const char *format, ...);
+
 typedef struct {
     char x,y; 
 } s;
--- a/test/regargs.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/regargs.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,5 @@
+int printf(const char *format, ...);
+
 
 int
 arg1(int a1,int a2,int a3,int a4)
--- a/test/short.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/short.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,4 @@
+int printf(const char *format, ...);
 
 short gj;
 short gi;
--- a/test/simp0.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/simp0.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,5 @@
+int printf(const char *format, ...);
+
 
 main(int ac,char *av[])
 {
--- a/test/simp1.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/simp1.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,6 @@
+int printf(const char *format, ...);
+
+
 int
 i(int a,int b,int c,int d,int f)
 {
--- a/test/static.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/static.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,4 @@
+int printf(const char *format, ...);
 
 
 f()
--- a/test/strinit.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/strinit.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,4 @@
+#include <stdio.h>
 
 int b[3] = {1,2,3};
 
--- a/test/switch.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/switch.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,5 @@
+#include <stdio.h>
+
 main(int ac,char *av[])
 {
     int i;
--- a/test/tmp.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/tmp.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,5 @@
+int printf(const char *format, ...);
+
 
 int
 main1(int ac,char *av[],int (*f)(),int g())
--- a/test/tmp11.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/tmp11.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,5 @@
+int printf(const char *format, ...);
+
 typedef struct nametable {
         char *nm;
         int sc,ty,dsp; } NMTBL;
--- a/test/tmp12.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/tmp12.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,4 @@
+int printf(const char *format, ...);
 
 
 struct {
--- a/test/tmp7.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/tmp7.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,4 @@
+int printf(const char *format, ...);
 
 
 int k=3;
--- a/test/tmp8.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/tmp8.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,5 @@
+int printf(const char *format, ...);
+
 #include <alloca.h>
 
 int asize = 100;
--- a/test/void_code.c	Mon May 16 11:53:56 2005 +0900
+++ b/test/void_code.c	Sat Jul 30 16:01:45 2005 +0900
@@ -1,3 +1,5 @@
+int printf(const char *format, ...);
+
 main()
 {
    int i;