diff mc-parse.c @ 203:28baf6cd9ad1

*** empty log message ***
author kono
date Tue, 13 Apr 2004 10:28:21 +0900
parents 601301152d9c
children 4c614334f3d0
line wrap: on
line diff
--- 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);