changeset 203:28baf6cd9ad1

*** empty log message ***
author kono
date Tue, 13 Apr 2004 10:28:21 +0900
parents 601301152d9c
children 4c614334f3d0
files Changes mc-code-ia32.c mc-code-mips.c mc-code-powerpc.c mc-parse.c test/code-gen.c
diffstat 6 files changed, 37 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Sun Apr 11 13:25:49 2004 +0900
+++ b/Changes	Tue Apr 13 10:28:21 2004 +0900
@@ -3875,3 +3875,14 @@
 ま、そうだよね。
 
 あと、#include の search path のセマンティクスを直さないと。
+
+Mon Apr 12 12:19:35 JST 2004
+
+3461        if (!integral(t=cadr(type))&&
+3462                    !(t==FLOAT||t==DOUBLE) &&
+3463                    !(t==LONGLONG||t==ULONGLONG) &&
+3464                    (car(t)==STRUCT||car(t)==UNION)) {
+
+じゃなくて、t>0 && (car(t)==STRUCT||car(t)==UNION)) {
+じゃないか?
+
--- a/mc-code-ia32.c	Sun Apr 11 13:25:49 2004 +0900
+++ b/mc-code-ia32.c	Tue Apr 13 10:28:21 2004 +0900
@@ -1134,6 +1134,7 @@
 int
 code_lrindirect(int e1, int offset, int us)
 {
+    return LONGLONG;
 }
 #endif
 
--- a/mc-code-mips.c	Sun Apr 11 13:25:49 2004 +0900
+++ b/mc-code-mips.c	Tue Apr 13 10:28:21 2004 +0900
@@ -1583,6 +1583,7 @@
     char *crn;
     g_expr(e1);
     crn=register_name(creg);
+    return LONGLONG;
 }
 #endif
 
--- a/mc-code-powerpc.c	Sun Apr 11 13:25:49 2004 +0900
+++ b/mc-code-powerpc.c	Tue Apr 13 10:28:21 2004 +0900
@@ -1487,7 +1487,7 @@
 	    freg_arg++;
 	    nargs += size(t)/size_of_int;
 	    continue;
-	} else if (car(t)==STRUCT||car(t)==UNION) {
+	} else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
 	    arg = list2(LVAR,caller_arg_offset_v(nargs));
 	    nargs += struct_push(e4,t,arg);
 	    continue;
--- a/mc-parse.c	Sun Apr 11 13:25:49 2004 +0900
+++ b/mc-parse.c	Tue Apr 13 10:28:21 2004 +0900
@@ -1,5 +1,4 @@
-/* Micro-C Parser Part */
-/* $Id$ */
+/* Micro-C Parser Part */ /* $Id$ */
 
 #define EXTERN /**/
 #include "mc.h"
@@ -632,7 +631,7 @@
 decl1(void)
 {
     NMTBL *n;
-    int i,t;
+    int i,array_type,arg;
 
     if(sym==LPAR) {
 	getsym(0);
@@ -657,10 +656,10 @@
 		    error(DCERR);
 		}
 	    } else {
-		t=type;
+		array_type=type;
 		i=cexpr(expr(1));
 		checksym(RBRA);
-		type=list3(ARRAY,t,i);
+		type=list3(ARRAY,array_type,i);
 	    }
 	} else if(sym==LPAR) { /* function or code segment */
 	    if(mode==GDECL) {
@@ -673,18 +672,18 @@
 	    if (type==CODE) {
 		n->ty=CODE;
 		if(sym==RPAR) {
-		    getsym(0);t=0;
+		    getsym(0);arg=0;
 		} else {
-		    t=adecl(n);
+		    arg=adecl(n);
 		}
-		type=glist3(CODE,CODE,t);
+		type=glist3(CODE,CODE,arg);
 	    } else {
 		if(sym==RPAR) {
-		    getsym(0);t=0;
+		    getsym(0);arg=0;
 		} else {
-		    t=adecl(n);
+		    arg=adecl(n);
 		}
-		type=glist3(FUNCTION,type,t);
+		type=glist3(FUNCTION,type,arg);
 	    }
 	    /* Do not set n->ty here. It could be K&R style arguments or
                struct field names */
@@ -692,7 +691,7 @@
                it contains arg type list. Real parameter list is compatible
                with arg type list. See def/ADECL  */
 	    if (mode!=GDECL)
-		n->dsp=t;
+		n->dsp=arg;
 	} else
 	    return n;
     }
@@ -1509,6 +1508,7 @@
 	    args = 0;
 	    def(&str_ret);
 	    struct_return = list3(list2(LVAR,str_ret.dsp),sz,type);
+	    caddr(fnptr->ty) = glist2(POINTER,caddr(fnptr->ty));
 	}
 	type = type_save;
 	mode = mode_save;
@@ -2700,6 +2700,7 @@
 {
     int e1;
     e1=list2(FNAME,(int)nptr);
+    // type=list3(FUNCTION,type,arg);
     type=list3(car(nptr->ty),cadr(nptr->ty),caddr(nptr->ty));
     getsym(0);
     extrn_use(nptr);
@@ -3261,6 +3262,8 @@
 {
     int e=0;
 
+    if(t1>0&&car(t1)==POINTER) { e2= int_value(e2,t2); t2=INT; }
+    else if(t2>0&&car(t2)==POINTER) { e1= int_value(e1,t1); t1=INT; }
 #if FLOAT_CODE
     if(t1==DOUBLE||t2==DOUBLE)
 	return dbinop(op,e1,e2,t1,t2);
@@ -3458,10 +3461,7 @@
     /* function argments */
 
     argtypes = caddr(type);
-    if (!integral(t=cadr(type))&&
-		!(t==FLOAT||t==DOUBLE) &&
-		!(t==LONGLONG||t==ULONGLONG) &&
-		(car(t)==STRUCT||car(t)==UNION)) {
+    if ((t=cadr(type))>=0 && (car(t)==STRUCT||car(t)==UNION)) {
 	/* skip return struct pointer */
 	if (argtypes==0) error(-1);
 	argtypes = cadr(argtypes);
--- a/test/code-gen.c	Sun Apr 11 13:25:49 2004 +0900
+++ b/test/code-gen.c	Tue Apr 13 10:28:21 2004 +0900
@@ -234,6 +234,13 @@
 }
 
 void
+code_return_struct1()
+{
+    int i = code_return_struct0().a[55];
+    printf("code_return_struct %d\n", i);
+}
+
+void
 code_return_struct()
 {
     printf("code_return_struct %d\n", code_return_struct0().a[55]);