diff mc-tree.c @ 564:25f431685d80

*** empty log message ***
author kono
date Tue, 10 Jan 2006 16:30:43 +0900
parents 588bb765b301
children 94d3a8c1b3e8
line wrap: on
line diff
--- a/mc-tree.c	Tue Jan 10 10:28:55 2006 +0900
+++ b/mc-tree.c	Tue Jan 10 16:30:43 2006 +0900
@@ -161,6 +161,21 @@
     {AS+BOR,"|=","ee"},
 };
 
+static int
+attr_print(int t)
+{
+    while (t>0 && car(t)==ATTRIBUTE) {
+	switch (caddr(t)) {
+	case KONST: printf( "const"); break;
+	case VOLATILE: printf( "volatile"); break;
+	case RESTRICT: printf( "restrict"); break;
+	case INLINE: printf( "inline"); break;
+	}
+	t = cadr(t);
+    }
+    return t;
+}
+
 void
 tree_print_t(int e,int t)
 {
@@ -315,6 +330,18 @@
     return 0;
 }
 
+static void n_attr_print(int attr, FILE *out)
+{
+    for(;attr;attr=cadr(attr)) {
+	switch(car(attr)) {
+	case INLINE: fprintf(out,"inline "); break;
+	case CONST: fprintf(out,"const "); break;
+	case VOLATILE: fprintf(out,"const "); break;
+	case RESTRICT: fprintf(out,"const "); break;
+	}
+    }
+}
+
 void type_print1(int type,NMTBL *n,FILE *out,int cont)
 {
     int t; 
@@ -322,6 +349,11 @@
     NMTBL *td;
     int args;
 
+    if (n) {
+	if (n->attr) n_attr_print(n->attr,out);
+	while(type>0 && car(type)==ATTRIBUTE) type=cadr(type);
+    } else
+	type = attr_print(type);
     if(type>0&&(td=typedef_search(typedefed,type))) {
 	if (!cont)
 	    fprintf(out,"%s ",td->nm);