changeset 537:a6c9ffbf3f08

arg offset in nested function arguments.
author kono
date Sat, 31 Dec 2005 17:16:14 +0900
parents a349f9c2aef5
children f9c6976ba270
files .gdbinit Changes Makefile mc-codegen.c mc-parse.c test/too-long-argument.c
diffstat 6 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/.gdbinit	Sat Dec 31 14:26:40 2005 +0900
+++ b/.gdbinit	Sat Dec 31 17:16:14 2005 +0900
@@ -43,4 +43,7 @@
 # run -s test/tmp7.c
 # run -s test/inline.c
 # run -s test/code-gen-inline.c
-run -s -DINLINE=inline test/basic.c
+# run -s -DINLINE=inline test/basic.c
+run -s test/too-long-argument.c
+
+
--- a/Changes	Sat Dec 31 14:26:40 2005 +0900
+++ b/Changes	Sat Dec 31 17:16:14 2005 +0900
@@ -7728,3 +7728,10 @@
         ret
 
 とかで stack のぶっこわしを検出できます。
+
+Sat Dec 31 17:08:08 JST 2005
+
+decl_data で ADECL をチェックしてないから、引数の初期化が
+あるな。C++ では、確かあったような気もするが...
+
+
--- a/Makefile	Sat Dec 31 14:26:40 2005 +0900
+++ b/Makefile	Sat Dec 31 17:16:14 2005 +0900
@@ -89,6 +89,7 @@
 	make check TARGET=test/switch
 	make check TARGET=test/strinit
 	make check TARGET=test/code-gen-all
+	make check TARGET=test/code-gen-inline
 	make check TARGET=test/bitfield
 	make check TARGET=test/bitfield1
 	make check TARGET=test/cext
--- a/mc-codegen.c	Sat Dec 31 14:26:40 2005 +0900
+++ b/mc-codegen.c	Sat Dec 31 17:16:14 2005 +0900
@@ -2472,7 +2472,7 @@
     NMTBL *n;
     for(e=inline_funcs;e;e=cadr(e)) {
 	n = (NMTBL*)car(e);
-	if (1 || n->sc==EXTRN || n->sc==EXTRN1 || has_attr(n,FNAME)) {  
+	if (/* 1 || */ n->sc==EXTRN || n->sc==EXTRN1 || has_attr(n,FNAME)) {  
             // global or used as pointer
 	    // generate possibly called inline function
 	    pfdecl(n);
--- a/mc-parse.c	Sat Dec 31 14:26:40 2005 +0900
+++ b/mc-parse.c	Sat Dec 31 17:16:14 2005 +0900
@@ -1061,9 +1061,11 @@
 		    getsym(0);arg=0;
 		} else {
 		    if (mode==ADECL) {
+			int sargs=args;
 			enter_scope();
 			arg=adecl(n);
 			leave_scope();
+			args=sargs;
 		    } else 
 			arg=adecl(n);
 		}
@@ -1073,9 +1075,11 @@
 		    getsym(0);arg=0;
 		} else {
 		    if (mode==ADECL) {
+			int sargs=args;
 			enter_scope();
 			arg=adecl(n);
 			leave_scope();
+			args=sargs;
 		    } else 
 			arg=adecl(n);
 		}
--- a/test/too-long-argument.c	Sat Dec 31 14:26:40 2005 +0900
+++ b/test/too-long-argument.c	Sat Dec 31 17:16:14 2005 +0900
@@ -12,7 +12,7 @@
 	code(*ret)(int),
 	void *env)
 {
-fprintf(stderr,"f1=%d,f2=%d,f3=%d,f4=%d,f5=%d,f6=%d,f7=%d,f8=%d,f9=%d,fa=%d,fb=%d,fc=%d,fd=%d,fe=%d,ff=%d\n",
+fprintf(stderr,"tcode2: f1=%d,f2=%d,f3=%d,f4=%d,f5=%d,f6=%d,f7=%d,f8=%d,f9=%d,fa=%d,fb=%d,fc=%d,fd=%d,fe=%d,ff=%d\n",
 f1,f2,f3,f4,f5,f6,f7,f8,f9,fa,fb,fc,fd,fe,ff);
      goto ret(0),env;
 }
@@ -23,7 +23,7 @@
 	code(*ret)(int);
 	void *env;
 {
-fprintf(stderr,"f1=%d,f2=%d,f3=%d,f4=%d,f5=%d,f6=%d,f7=%d,f8=%d,f9=%d,fa=%d,fb=%d,fc=%d,fd=%d,fe=%d,ff=%d\n",
+fprintf(stderr,"tcode1: f1=%d,f2=%d,f3=%d,f4=%d,f5=%d,f6=%d,f7=%d,f8=%d,f9=%d,fa=%d,fb=%d,fc=%d,fd=%d,fe=%d,ff=%d\n",
 f1,f2,f3,f4,f5,f6,f7,f8,f9,fa,fb,fc,fd,fe,ff);
      goto ret(0),env;
 }
@@ -87,9 +87,13 @@
 int
 main()
 {
+    printf("main4\n");
     main4();
+    printf("main2\n");
     main2();
+    printf("main0\n");
     main0();
+    printf("main1\n");
     main1();
 }