diff mc-parse.c @ 436:d92786033042 loprtc-div

loprtc
author kono
date Sun, 14 Nov 2004 15:41:05 +0900
parents fb136af3bf09
children 626d705471d5
line wrap: on
line diff
--- a/mc-parse.c	Thu Nov 11 00:39:37 2004 +0900
+++ b/mc-parse.c	Sun Nov 14 15:41:05 2004 +0900
@@ -2569,12 +2569,24 @@
 #if LONGLONG_CODE
 	if(type==LONGLONG||type==ULONGLONG) {
 	    // return list2(LMINUS,e);
-	    return(car(e)==LCONST?llist2(LCONST,-lcadr(e)):list2(LMINUS,e));
+	    if (car(e)==LCONST) {
+		if (lcadr(e)>0 && type==ULONGLONG) { type=LONGLONG;
+		} else if (lcadr(e)<=0 && type==LONGLONG) { type=ULONGLONG;
+		}
+		return llist2(LCONST,-lcadr(e));
+	    }
+	    return list2(LMINUS,e);
 	}
 #endif
 	if(!integral(type))
 	    error(TYERR);
-	return(car(e)==CONST?list2(CONST,-cadr(e)):list2(MINUS,e));
+	if (car(e)==CONST) {
+	    if (cadr(e)>0 && type==UNSIGNED) { type=INT;
+	    } if (cadr(e)<=0 && type==INT) { type=UNSIGNED;
+	    } 
+	    return list2(CONST,-cadr(e));
+	}
+	return list2(MINUS,e);
     case BNOT: /* ~p */
 	conv->prefix_(sym);
 	getsym(0);
@@ -2801,7 +2813,7 @@
 	break;
     case CONST:
 	conv-> const_(symval);
-	type= INT;
+	type= symval>=0?UNSIGNED:INT;
 	e1=list2(CONST,symval);
 	getsym(0);
 	break;
@@ -2822,7 +2834,7 @@
 #if LONGLONG_CODE
     case LCONST:
 	conv-> const_(symval);
-	type= LONGLONG;
+	type= ULONGLONG;
 	e1=llist2(LCONST,lsymval);
 	getsym(0);
 	break;