changeset 698:c6567d33cf21

struct argument alignment in parse mode.
author kono
date Mon, 22 Oct 2007 00:06:31 +0900
parents e31cba38f7fc
children 0bc5f2ff86cc
files mc-parse.c test/obsf.c
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mc-parse.c	Sun Oct 21 20:54:47 2007 +0900
+++ b/mc-parse.c	Mon Oct 22 00:06:31 2007 +0900
@@ -2256,6 +2256,9 @@
     
     // make copied called function argment
     for(args=n->dsp,nargs=0;args;args=cadr(args)) {
+	int t; 
+	int sz ;
+
 	n1 = get_nptr();
 	a = (NMTBL*)caddr(args);
 	n1->ty = a->ty;
@@ -2263,8 +2266,14 @@
 	n1->sc = a->sc==IVAR?LVAR:a->sc;
 	n1->attr = a->attr;
 
+	t = type_value(n1->ty);
+	sz = size(t);
+
 	n1->dsp = offset;
-	offset+= (scalar(n1->ty))?size_of_int:size(n1->ty);
+	offset+= (scalar(t))?size_of_int:
+	         (t>0&&(car(t)==UNION||car(t)==STRUCT))?
+		    ((sz+(size_of_int-1))&~(size_of_int-1)):
+		    sz;
 
 	nargs=list4(car(args),nargs,(int)n1,cadddr(args));
     }
--- a/test/obsf.c	Sun Oct 21 20:54:47 2007 +0900
+++ b/test/obsf.c	Mon Oct 22 00:06:31 2007 +0900
@@ -3,7 +3,7 @@
 main(t,_,a)
 char *a;
 {
-printf("%d %d %d\n",t,_,a);
+// printf("%d %d %d\n",t,_,a);
 return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
 main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a
 )&&t == 2 ?_<13 ?main ( 2, _+1, "%s %d %d\n" ):9:16:t<0?t<-72?main(_,