changeset 569:1fcad06b264a

gcc4 (ia32)
author kono
date Thu, 12 Jan 2006 01:54:14 +0900
parents 559eb65d1289
children 266ded1a8fef
files Changes Makefile mc-code-arm.c mc-code-ia32.c mc-code-mips.c mc-code-powerpc.c mc-codegen.c mc-inline.c mc-macro.c mc-parse.c mc-switch.c stdio.h
diffstat 12 files changed, 241 insertions(+), 105 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Wed Jan 11 18:30:24 2006 +0900
+++ b/Changes	Thu Jan 12 01:54:14 2006 +0900
@@ -8211,3 +8211,25 @@
 
 long long のEQ/NEQ が、long long を返しているようですが。
 
+ -O99 だと、mc1 が落ちて、mc2 は落ちない。ってことは、
+なんか余計なレジスタが干渉しているらしい。
+
+  PowerPC で -O99 だと、cmpflag 4 が保存されることを gcc4  
+が要求するらしい。
+
++leo+kono time ./mc  mc*.c 
+./mc mc*.c  0.93s user 0.11s system 93% cpu 1.105 total
++leo+kono time ./mc1  mc*.c
+./mc1 mc*.c  1.21s user 0.11s system 93% cpu 1.406 total
++leo+kono time ./mc2  mc*.c
+./mc2 mc*.c  1.19s user 0.12s system 84% cpu 1.542 total
+   gcc 最適化なし
++leo+kono time ./mc  mc*.c
+./mc mc*.c  1.34s user 0.12s system 93% cpu 1.556 total
+
+コンパイラぐらいだとgcc4 の -O99 の20%ぐらいの速度差らしい。gcc の最適化なし
+よりは速いのか。
+
+ -O99 の初期化してないっていうエラーメッセージに対処するために
+いろいろ初期化を入れちゃったけど、本当は必要ない。
+
--- a/Makefile	Wed Jan 11 18:30:24 2006 +0900
+++ b/Makefile	Thu Jan 12 01:54:14 2006 +0900
@@ -1,6 +1,6 @@
-CC = gcc -std=c99
-# -O3
-CFLAGS = -g -Wall -I.
+CC = gcc -std=c99 -O2
+#  -O99
+CFLAGS = -g -Wall -I. 
 # CFLAGS = -g -Wall -I. -pg -fprofile-arcs -ftest-coverage
 # LDFLAGS = -pg
 # for Linux Zaurus
--- a/mc-code-arm.c	Wed Jan 11 18:30:24 2006 +0900
+++ b/mc-code-arm.c	Thu Jan 12 01:54:14 2006 +0900
@@ -21,6 +21,34 @@
     "/usr/include",
     0};
 
+// va_start, va_arg is wrong, use va_arm.h
+
+static char *init_src0 = "\
+/* #define __builtin_va_list int */\n\
+/* #define __builtin_va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg)) */\n\
+/* #define __builtin_va_arg(ap,type)  (*((type *)ap)++) */\n\
+#define __builtin_next_arg(arg)  (__gnuc_va_list)((char *)(&arg) + __va_rounded_size (typeof(arg)))\n\
+#define __arm__ 1\n\
+#define __STDC__ 1\n\
+#define __SIZE_TYPE__ int\n\
+#define __attribute__(a)\n\
+#define __flexarr\n\
+#define __WCHAR_TYPE__ int\n\
+#define __alignof__(type) (sizeof(type)==1?1:sizeof(type)==2?2:sizeof(type)<=4?4:8)\n\
+#define __PTRDIFF_TYPE__ int\n\
+#define __GNUC__ 2\n\
+#define __const const\n\
+#define alloca __builtin_alloca\n\
+#define __restrict\n\
+#define __flexarr\n\
+#define __const const\n\
+#define __THORW\n\
+// #define __attribute__(a)\n\
+#define __inline__ inline\n\
+#define size_t int\n\
+#define wchar_t int\n\
+";
+
 int data_alignment = 0;
 
 #define TEXT_EMIT_MODE 0
@@ -512,35 +540,6 @@
 }
 
 
-// va_start, va_arg is wrong, use va_arm.h
-
-static char *init_src0 = "\
-/* #define __builtin_va_list int */\n\
-/* #define __builtin_va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg)) */\n\
-/* #define __builtin_va_arg(ap,type)  (*((type *)ap)++) */\n\
-#define __builtin_next_arg(arg)  (__gnuc_va_list)((char *)(&arg) + __va_rounded_size (typeof(arg)))\n\
-#define __arm__ 1\n\
-#define __inline__\n\
-#define __STDC__ 1\n\
-#define __SIZE_TYPE__ int\n\
-#define __attribute__(a)\n\
-#define __flexarr\n\
-#define __WCHAR_TYPE__ int\n\
-#define __alignof__(type) (sizeof(type)==1?1:sizeof(type)==2?2:sizeof(type)<=4?4:8)\n\
-#define __PTRDIFF_TYPE__ int\n\
-#define __GNUC__ 2\n\
-#define __const const\n\
-#define alloca __builtin_alloca\n\
-#define __restrict\n\
-#define __flexarr\n\
-#define __const const\n\
-#define __THORW\n\
-#define __attribute__(a)\n\
-#define __inline__\n\
-#define size_t int\n\
-#define wchar_t int\n\
-";
-
 void
 code_init(void)
 {
@@ -1187,7 +1186,7 @@
 int
 emit_push()
 {
-    int new_reg,old;
+    int new_reg,old=creg;
     if (!is_int_reg(creg)) error(-1);
     if (reg_sp>MAX_MAX) error(-1);
     new_reg = get_register();       /* 絶対に取れる */
@@ -1387,7 +1386,7 @@
 {
     int sign,im,jm,km;
     int min_stage = 4;
-    int msign,mim,mjm,mkm;
+    int msign=0,mim=0,mjm,mkm;
     int id,jd,kd;
     int i,j,k;
     int d;
@@ -1465,7 +1464,7 @@
 static int
 is_stage1_const(int c,int mode)
 {
-    int sign,p1,p2,p3;
+    int sign,p1=0,p2=0,p3=0;
     sign = make_const(c,&p1,&p2,&p3,mode);
     return (c==0||(p1&&!p2&&!p3))?sign:0;
 }
@@ -2360,7 +2359,7 @@
 static void
 code_assign_input_double_long(int e1,int e2) {
 #if FLOAT_CODE
-    int r,tmp=-1,reg;
+    int r,tmp=-1,reg=0;
     double value;
     //  e1 = e2;
     if (car(e1)!=LREGISTER) { error(-1); return; }
@@ -2527,6 +2526,7 @@
     stargs = 0;
     complex_ = 0;
     nargs = reg_arg = freg_arg = 0;
+    pnargs = preg_arg = pfreg_arg = 0;
     for (e3 = e1 = reverse0(caddr(e1)); e3; e3 = cadr(e3)) {	
 	t=caddr(e3);
 	if (reg_arg==3 && (t==DOUBLE||t==LONGLONG||t==ULONGLONG)) {
@@ -3183,7 +3183,7 @@
     char *rn2;
     char *rn1;
     char *rn0;
-    char *cc,*ncc;
+    char *cc=0,*ncc=0;
 
     if (mode==COND_BRANCH_CONST||mode==COND_VALUE_CONST) {
 	rn1 =		register_name(r1);
@@ -4880,8 +4880,8 @@
 int
 drexpr(int e1, int e2,int l1, int op,int cond)
 {
-    int op1;
-    char *opn;
+    int op1=0;
+    char *opn=0;
     if (!cond) {
 	switch(op) {
 	    case FOP+GT:
@@ -5352,8 +5352,8 @@
     char *crn_h;
     char *crn_l;
     char *grn;
-    int v;
-    int vh;
+    int v=0;
+    int vh=0;
     int greg,dx=-1;
 
     use_longlong(creg);
@@ -6013,8 +6013,8 @@
 set_bitsz(int type,int *pbitpos, int *pbitsize,
 	int *psign,int *pbitsz,int *palign,int *pl)
 { 
-    int sign=0,bitsz; 
-    int align,l=0;
+    int sign=0,bitsz=0; 
+    int align=0,l=0;
     switch(cadr(type)) {   /* value type */
     case INT:	        sign=1; break; 
     case UNSIGNED:	break; 
@@ -6069,7 +6069,7 @@
     int bitsize,bitpos0;
     set_bitsz(type,&bitpos0,&bitsize,&sign,&bitsz,&align,&l);
 
-    if (bitsize>bitsz) { error(BTERR); bitsize = i; }
+    if (bitsize>bitsz) { error(BTERR); bitsize = bitsz; }
 
     /* bfd means previous bit field bit offset */
     if (bitpos) {
@@ -6086,7 +6086,7 @@
 	    offset+=i; bitpos-=i*8;
 	}
 	if (bitpos+bitsize > bitsz) {
-	    int stype;
+	    int stype=UNSIGNED;
 
 	    /* rewind extra previous offset */
 	    bitpos = *bfd; offset=*poffset;
--- a/mc-code-ia32.c	Wed Jan 11 18:30:24 2006 +0900
+++ b/mc-code-ia32.c	Thu Jan 12 01:54:14 2006 +0900
@@ -7,6 +7,107 @@
 #include "mc-codegen.h"
 #include "mc-code.h"
 
+#if defined(__GNUC__) && __GNUC__ >= 4
+
+char *l_include_path[] = {
+    "/usr/local/include",
+    "/usr/lib/gcc/i486-linux-gnu/4.0.3/include",
+    "/usr/include/",
+    0
+};
+
+static
+char *init_src0 = "\
+#define __builtin_va_list int\n\
+#define __builtin_va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\
+#define __builtin_va_arg(ap,type)  (*((type *)ap)++)\n\
+#define alloca __builtin_alloca\n\
+#define __STDC__ 1\n\
+#define __extension__\n\
+#define __STDC__ 1\n\
+#define __flexarr\n\
+#define __const const\n\
+#define __THORW\n\
+#define __inline__ inline\n\
+\n\
+#define __DBL_MIN_EXP__ (-1021)\n\
+#define __FLT_MIN__ 1.17549435e-38F\n\
+#define __CHAR_BIT__ 8\n\
+#define __WCHAR_MAX__ 2147483647\n\
+#define __DBL_DENORM_MIN__ 4.9406564584124654e-324\n\
+#define __FLT_EVAL_METHOD__ 2\n\
+#define __DBL_MIN_10_EXP__ (-307)\n\
+#define __FINITE_MATH_ONLY__ 0\n\
+#define __GNUC_PATCHLEVEL__ 3\n\
+#define __SHRT_MAX__ 32767\n\
+#define __LDBL_MAX__ 1.18973149535723176502e+4932L\n\
+#define __UINTMAX_TYPE__ long long unsigned int\n\
+#define __linux 1\n\
+#define __unix 1\n\
+#define __LDBL_MAX_EXP__ 16384\n\
+#define __linux__ 1\n\
+#define __SCHAR_MAX__ 127\n\
+#define __USER_LABEL_PREFIX__ \n\
+#define __STDC_HOSTED__ 1\n\
+#define __LDBL_HAS_INFINITY__ 1\n\
+#define __DBL_DIG__ 15 \n\
+#define __FLT_EPSILON__ 1.19209290e-7F\n\
+#define __unix__ 1\n\
+#define __DECIMAL_DIG__ 21\n\
+#define __gnu_linux__ 1\n\
+#define __LDBL_HAS_QUIET_NAN__ 1\n\
+#define __GNUC__ 4\n\
+#define __DBL_MAX__ 1.7976931348623157e+308\n\
+#define __DBL_HAS_INFINITY__ 1\n\
+#define __DBL_MAX_EXP__ 1024\n\
+#define __LONG_LONG_MAX__ 9223372036854775807LL\n\
+#define __GXX_ABI_VERSION 1002\n\
+#define __FLT_MIN_EXP__ (-125)\n\
+#define __DBL_MIN__ 2.2250738585072014e-308\n\
+#define __DBL_HAS_QUIET_NAN__ 1\n\
+#define __REGISTER_PREFIX__ \n\
+#define __NO_INLINE__ 1\n\
+#define __i386 1\n\
+#define __FLT_MANT_DIG__ 24\n\
+#define __VERSION__ \"micro-c $Id$\"\n\
+#define i386 1\n\
+#define __i486__ 1\n\
+#define unix 1\n\
+#define __i386__ 1\n\
+#define __SIZE_TYPE__ unsigned int\n\
+#define __ELF__ 1\n\
+#define __FLT_RADIX__ 2\n\
+#define __FLT_HAS_QUIET_NAN__ 1\n\
+#define __FLT_MAX_10_EXP__ 38\n\
+#define __LONG_MAX__ 2147483647L\n\
+#define __FLT_HAS_INFINITY__ 1\n\
+#define linux 1\n\
+#define __LDBL_MANT_DIG__ 64\n\
+#define __WCHAR_TYPE__ int\n\
+#define __FLT_DIG__ 6\n\
+#define __INT_MAX__ 2147483647\n\
+#define __i486 1\n\
+#define __FLT_MAX_EXP__ 128\n\
+#define __DBL_MANT_DIG__ 53\n\
+#define __WINT_TYPE__ unsigned int\n\
+#define __LDBL_MIN_EXP__ (-16381)\n\
+#define __LDBL_MAX_10_EXP__ 4932\n\
+#define __DBL_EPSILON__ 2.2204460492503131e-16\n\
+#define __tune_i486__ 1\n\
+#define __INTMAX_MAX__ 9223372036854775807LL\n\
+#define __FLT_DENORM_MIN__ 1.40129846e-45F\n\
+#define __FLT_MAX__ 3.40282347e+38F\n\
+#define __FLT_MIN_10_EXP__ (-37)\n\
+#define __INTMAX_TYPE__ long long int\n\
+#define __GNUC_MINOR__ 0\n\
+#define __DBL_MAX_10_EXP__ 308\n\
+#define __PTRDIFF_TYPE__ int\n\
+#define __LDBL_MIN_10_EXP__ (-4931)\n\
+#define __LDBL_DIG__ 18\n\
+";
+
+#else
+
 char *l_include_path[] = {
     "/usr/include/",
     "/usr/include/linux/",
@@ -17,6 +118,30 @@
     0
 };
 
+static
+char *init_src0 = "\
+#define va_list int\n\
+#define va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\
+#define va_arg(ap,type)  (*((type *)ap)++)\n\
+#define va_end\n\
+#define __i386__ 1\n\
+#define __LITTLE_ENDIAN__ 1\n\
+#define __STDC__ 1\n\
+#define size_t int\n\
+#define __extension__\n\
+// #define __restrict\n\
+#define __gnuc_va_list int\n\
+#define __flexarr\n\
+#define __const const\n\
+#define __THORW\n\
+// #define __attribute__(a)\n\
+#define __inline__ inline\n\
+#define wchar_t int\n\
+#define __GNUC__ 2\n\
+";
+
+#endif
+
 int data_alignment = 0;
 
 #define    SIZE_OF_INT  4
@@ -223,28 +348,6 @@
     return i==REG_L?"%esi":"%eax";
 }
 
-static
-char *init_src0 = "\
-#define va_list int\n\
-#define va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\
-#define va_arg(ap,type)  (*((type *)ap)++)\n\
-#define va_end\n\
-#define __i386__ 1\n\
-#define __LITTLE_ENDIAN__ 1\n\
-#define __STDC__ 1\n\
-#define size_t int\n\
-#define __externsion__\n\
-#define __restrict\n\
-#define __gnuc_va_list int\n\
-#define __flexarr\n\
-#define __const const\n\
-#define __THORW\n\
-#define __attribute__(a)\n\
-#define __inline__\n\
-#define wchar_t int\n\
-#define __GNUC__ 2\n\
-";
-
 extern void
 code_init(void)
 {
@@ -2021,6 +2124,8 @@
 	    printf("%cn",92);
 	else if (*s<' ')
 	    printf("%c%03o",92,*s);
+	else if (*s=='\\')
+	    printf("\\\\");
 	else if (*s==34)
 	    printf("%c%c",92,34);
 	else 
@@ -3023,10 +3128,10 @@
 }
 
 void loprtc(int op,int reg,int e) {
-    char *opl,*oph;
+    char *opl,*oph=0;
     int vl,il;
     int vh;
-    long long l;
+    long long l=0;
 
     if (car(e)==CONST) l = cadr(e);
     else if (car(e)==LCONST) l = lcadr(e);
@@ -3521,8 +3626,8 @@
 set_bitsz(int type,int *pbitpos, int *pbitsize,
 	int *psign,int *pbitsz,int *palign,int *pl)
 { 
-    int sign=0,bitsz; 
-    int align,l=0;
+    int sign=0,bitsz=1; 
+    int align=4,l=0;
     *pbitpos = cadr(caddr(type));
     *pbitsize = caddr(caddr(type));
 
@@ -3560,7 +3665,7 @@
     int l;
     set_bitsz(type,&bitpos0,&bitsize,&sign,&bitsz,&align,&l);
 
-    if (bitsize>bitsz) { error(BTERR); bitsize = i; }
+    if (bitsize>bitsz) { error(BTERR); bitsize = bitsz; }
 
     /* bfd means previous bit field bit offset */
     if (bitpos) {
--- a/mc-code-mips.c	Wed Jan 11 18:30:24 2006 +0900
+++ b/mc-code-mips.c	Thu Jan 12 01:54:14 2006 +0900
@@ -23,11 +23,11 @@
 #define __builtin_next_arg(arg)  ap=((void *)(&arg)),va_arg(ap,typeof(arg))\n\
 #define __mips__ 1\n\
 #define __LITTLE_ENDIAN__ 1\n\
-#define __inline__\n\
+#define __inline__ inline\n\
 #define __STDC__ 1\n\
 #define __SIZE_TYPE__ int\n\
 #define __extension__\n\
-#define __attribute__(a)\n\
+// #define __attribute__(a)\n\
 #define __flexarr\n\
 #define __WCHAR_TYPE__ int\n\
 #define __alignof__(type) (sizeof(type)==1?1:sizeof(type)==2?2:sizeof(type)<=4?4:8)\n\
@@ -2092,7 +2092,7 @@
     NMTBL *fn = 0;
     int jmp = 0;
     int complex_;
-    int pnargs,preg_arg,pfreg_arg;
+    int pnargs=0,preg_arg=0,pfreg_arg=0;
     int stargs;
 
     special_lvar = -1;
@@ -4226,7 +4226,7 @@
 int
 drexpr(int e1, int e2,int l1, int op,int cond)
 {
-    int op1;
+    int op1=0;
     if (!cond) {
 	switch(op) {
 	    case FOP+GT:
@@ -4879,6 +4879,7 @@
 
     if (car(e)==LCONST) v = lcadr(e);
     else if (car(e)==CONST) v = cadr(e);
+    else { v=0; error(-1); }
 
     switch(op) {
     case LMUL: case LUMUL:
@@ -5531,8 +5532,8 @@
 set_bitsz(int type,int *pbitpos, int *pbitsize,
 	int *psign,int *pbitsz,int *palign,int *pl)
 { 
-    int sign=0,bitsz; 
-    int align,l=0;
+    int sign=0,bitsz=0; 
+    int align=4,l=0;
     *pbitpos = cadr(caddr(type));
     *pbitsize = caddr(caddr(type));
     switch(cadr(type)) {  /* value type */
@@ -5568,7 +5569,7 @@
     int bitsize,bitpos0;
     set_bitsz(type,&bitpos0,&bitsize,&sign,&bitsz,&align,&l);
 
-    if (bitsize>bitsz) { error(BTERR); bitsize = i; }
+    if (bitsize>bitsz) { error(BTERR); bitsize = bitsz; }
 
     /* bfd means previous bit field bit offset */
     if (bitpos) {
--- a/mc-code-powerpc.c	Wed Jan 11 18:30:24 2006 +0900
+++ b/mc-code-powerpc.c	Thu Jan 12 01:54:14 2006 +0900
@@ -1458,12 +1458,13 @@
 
 #define code_eq(cond) (cond?"eq":"ne")
 
-static int cmpflag = 0;
+static int cmpflag = 7;
 
 static void
 inc_cmpflag()
 {
-    cmpflag = (cmpflag+1)%8;
+    //  gcc use cmpflag 4 and 7, and gcc4 believes flag 4 is preserved.
+    // cmpflag = (cmpflag+1)%8;
 }
 
 void
@@ -2007,7 +2008,7 @@
     int jmp = 0;
     char *jrn;
     int complex_;
-    int pnargs,preg_arg,pfreg_arg;
+    int pnargs=0,preg_arg=0,pfreg_arg=0;
     int stargs;
 
     special_lvar = -1;
@@ -2712,7 +2713,7 @@
 int
 rexpr(int e1, int l1, int cond,int t)
 {       
-    char *s;
+    char *s=0;
     switch(car(e1)+BNOT*(!cond)) {
     case GT:  s=code_gt(1);  break;
     case UGT: s=code_ugt(1); break;
@@ -4655,7 +4656,7 @@
     char *crn_h;
     char *crn_l;
     char *grn;
-    int v;
+    int v=0;
     int greg;
 
     use_longlong(creg);
@@ -5358,8 +5359,8 @@
 set_bitsz(int type,int *pbitpos,int *pbitsize,
 	int *psign,int *pbitsz,int *palign,int *pl)
 { 
-    int sign=0,bitsz; 
-    int align,l=0;
+    int sign=0,bitsz=0; 
+    int align=4,l=0;
     *pbitpos = cadr(caddr(type));
     *pbitsize = caddr(caddr(type));
     switch(cadr(type)) {   /* value type */
@@ -5396,7 +5397,7 @@
     int l;
     set_bitsz(type,&bitpos0,&bitsize,&sign,&bitsz,&align,&l);
 
-    if (bitsize>bitsz) { error(BTERR); bitsize = i; }
+    if (bitsize>bitsz) { error(BTERR); bitsize = bitsz; }
 
     /* bfd means previous bit field bit offset */
     if (bitpos) {
--- a/mc-codegen.c	Wed Jan 11 18:30:24 2006 +0900
+++ b/mc-codegen.c	Thu Jan 12 01:54:14 2006 +0900
@@ -869,7 +869,7 @@
 extern void
 parallel_rassign(int assigns)
 {
-    int free,tmp,remains,t0,t2,src;
+    int free,tmp,remains,t0=0,t2,src;
     tmp = 0;
     for(;;) {
 	remains = 0;
@@ -1755,7 +1755,7 @@
 static void
 dassign(int e1)
 {
-    int e2,e3,e4,d,e5;
+    int e2,e3,e4,d=0,e5;
 
     /*    e2=e4 */
     e2 = cadr(e1);
@@ -2244,7 +2244,7 @@
 extern int
 assop(int e1,int e2,int op,int t,int no_float)
 {
-    int ass,u = 0;
+    int ass=0,u = 0;
     int t0 = type_value(type);
     if(!(integral(t0)||t0==FLOAT||t0==DOUBLE||
 	t0==LONGLONG||t0==ULONGLONG
--- a/mc-inline.c	Wed Jan 11 18:30:24 2006 +0900
+++ b/mc-inline.c	Thu Jan 12 01:54:14 2006 +0900
@@ -234,7 +234,7 @@
 extern void
 st_case(int e1){
 #if CASE_CODE
-    int l,clist=caddr(e1),c;
+    int l=0,clist=caddr(e1),c;
     int cst = (car(csvalue1)==CONST);
     if (cst) {
 	c=cadr(csvalue1);
@@ -635,7 +635,7 @@
     int ctmode=cadddr(e);
     NMTBL *n=(NMTBL*)caddr(e);
     int dsp = n->dsp;
-    int v;
+    int v=0;
     int sstmode = stmode;
     int smode = mode;
     // in real partial evaluation, we have to check whether this variable
--- a/mc-macro.c	Wed Jan 11 18:30:24 2006 +0900
+++ b/mc-macro.c	Thu Jan 12 01:54:14 2006 +0900
@@ -417,7 +417,7 @@
 macro_processing()
 {
     int i;
-    int c;
+    int c=0;
     int mode_save;
     int next;
 
--- a/mc-parse.c	Wed Jan 11 18:30:24 2006 +0900
+++ b/mc-parse.c	Thu Jan 12 01:54:14 2006 +0900
@@ -1,6 +1,8 @@
 /* Micro-C Parser Part */ /* $Id$ */
 
 #include <stdio.h>
+// #include <stdlib.h>  // for malloc
+
 #include "mc.h"
 #include "mc-parse.h"
 #include "mc-codegen.h"
@@ -271,7 +273,7 @@
 	heapsize *= 2;
 	if (HEAP_REPORT)
 	    fprintf(stderr,"** heap extended to %d\n",heapsize);
-	heap = realloc(heap,heapsize*sizeof(int));
+	heap = (int*)realloc(heap,heapsize*sizeof(int));
 	if(!heap) { error(MMERR); exit(1); }
     }
     set_lfree(heapsize);
@@ -645,6 +647,7 @@
     char *s,*t;
     struct cheap scheap,scheap1;
     save_cheap(&scheap,cheap);
+    save_cheap(&scheap1,cheap); // make gcc happy
 
     if (! *filename) filename="mcout";
     for (t=0,s=filename;(*cheap->ptr = *s);cheap=increment_cheap(cheap,&p)) {
@@ -1125,6 +1128,9 @@
 		    type=list2(POINTER,type);
 		} else if (mode==GDECL || stmode==EXTRN) {
 		    type=list3(ARRAY,type,0);
+		} else if (mode==GSDECL || mode==LSDECL) {
+		    // flexible array members
+		    type=list3(ARRAY,type,0);
 		} else {
 		    error(DCERR);
 		}
@@ -1526,7 +1532,7 @@
 static int
 decl_data(int t, NMTBL *n,int offset,int skip)
 {
-    int t0,t1,e,i,mode_save,lc=0;
+    int t0,t1=0,e,i,mode_save,lc=0;
 
     conv->decl_data_();
     t0 = type_value(t);
@@ -2133,7 +2139,7 @@
 static void
 doif(void)
 {
-    int l1,l2,slfree,pparse;
+    int l1,l2=0,slfree,pparse=0;
     getsym(0);
     checksym(LPAR);
     conv->if_();
@@ -2182,7 +2188,7 @@
 static void
 dowhile(void)
 {
-    int sbreak,scontinue,slfree,e,pparse;
+    int sbreak,scontinue,slfree,e,pparse=0;
 
     sbreak=blabel;
     scontinue=clabel;
@@ -2235,7 +2241,7 @@
 static void
 dodo(void)
 {
-    int sbreak,scontinue,l,slfree,pparse,e;
+    int sbreak,scontinue,l=0,slfree,pparse=0,e;
 
     sbreak=blabel;
     scontinue=clabel;
@@ -2281,8 +2287,8 @@
 static void
 dofor(void)
 {
-    int pparse,p0,p1;
-    int l,e,slfree,dflag=0;
+    int pparse=0,p0=0,p1=0;
+    int l=0,e=0,slfree,dflag=0;
     int sbreak=blabel;
     int slimit = lfree_type_limit;
     int sinit_vars = init_vars; 
@@ -2442,7 +2448,7 @@
 static void
 doswitch(void)
 {
-    int sbreak,scase,sdefault,slfree,svalue,slist;
+    int sbreak=0,scase=0,sdefault=0,slfree=0,svalue=0,slist=0;
     int pparse = parse,v,cst=0;
 
     checkret();
@@ -2554,7 +2560,7 @@
 docase(void)
 {
 #if CASE_CODE
-    int l,clist=0,c,cst = (car(csvalue1)==CONST);
+    int l=0,clist=0,c,cst = (car(csvalue1)==CONST);
     if (!inmode && !cst)
 	l = fwdlabel();
     while(sym==CASE) {
--- a/mc-switch.c	Wed Jan 11 18:30:24 2006 +0900
+++ b/mc-switch.c	Thu Jan 12 01:54:14 2006 +0900
@@ -186,7 +186,7 @@
 table_jump(int count,int delta,int chunks)
 {
     int list,i;
-    int l,max,min;
+    int l,max=0,min;
     if (!code_table_jump_p(delta))
 	return cascade_compare(count,chunks);
 
--- a/stdio.h	Wed Jan 11 18:30:24 2006 +0900
+++ b/stdio.h	Thu Jan 12 01:54:14 2006 +0900
@@ -1,13 +1,14 @@
-#ifndef __micro_c__
+#ifndef __micro_c___
 #include "/usr/include/stdio.h"
 long long strtoll(const char *, char **, int);
-char *malloc(int);
+void * malloc(size_t size);
 void * realloc(void *ptr, size_t size);
 #else
 
 // typedef int size_t;
 #define size_t int
 
+void * malloc(size_t size);
 long long strtoll(const char *, char **, int);
 void * realloc(void *ptr, size_t size);