From dc4cacf854d28a0df88e37e2f0c0abce421657a9 Mon Sep 17 00:00:00 2001 From: Teddy Date: Wed, 26 Mar 2014 19:50:34 +0800 Subject: problem caused by `void *` --- Makefile | 4 ++-- semantics.c | 10 +++++----- test.c | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 88bf597..fc9fe09 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,6 @@ clean: sem: semantics.o test.o gcc -o sem semantics.o test.o semantics.o: semantics.c - gcc -c semantics.c -Wall -Wextra + gcc -c semantics.c -Wall -Wextra -g test.o: test.c - gcc -c test.c -Wall -Wextra + gcc -c test.c -Wall -Wextra -g diff --git a/semantics.c b/semantics.c index 0913e65..cb12c29 100644 --- a/semantics.c +++ b/semantics.c @@ -108,23 +108,23 @@ void cscope_exit(CScope_t cs) { void ctable_debug_print(CTable_t ct) { int i; - fprintf(stderr, "\n*** CTable ***\n"); + fprintf(stderr, "*** CTable ***\n"); for (i = 0; i < MAX_TABLE_SIZE; i++) if (ct->head[i]) { CTNode *p; fprintf(stderr, "[%04d]", i); for (p = ct->head[i]; p; p = p->next) - fprintf(stderr, "->[%s:%d]", ct->pfunc(p), p->lvl); + fprintf(stderr, "->[%s:%d]", ct->pfunc(p->val), p->lvl); fprintf(stderr, "\n"); } - fprintf(stderr, "*** CTable ***\n\n"); + fprintf(stderr, "*** CTable ***\n"); } void cscope_debug_print(CScope_t cs) { int lvl = cs->lvl; CSNode *p; - fprintf(stderr, "****** CScope ******\n"); + fprintf(stderr, "\n****** CScope ******\n"); for (p = cs->top; p; p = p->next) { CVar *vp; @@ -142,7 +142,7 @@ void cscope_debug_print(CScope_t cs) { ctable_debug_print(cs->tvar); fprintf(stderr, "Type Table:\n"); ctable_debug_print(cs->ttype); - fprintf(stderr, "****** CScope ******\n"); + fprintf(stderr, "****** CScope ******\n\n"); } CVar *cscope_lookup_var(CScope_t cs, const char *name) { diff --git a/test.c b/test.c index 21314b1..3a80510 100644 --- a/test.c +++ b/test.c @@ -1,6 +1,7 @@ #include #include "semantics.h" #define PV(str) cscope_push_var(scope, newvar(str)) +#define PT(str) cscope_push_type(scope, newtype(str)) CVar_t newvar(const char *name) { return cvar_create(name, NULL); @@ -21,11 +22,13 @@ int main() { cscope_enter(scope); PV("a"); PV("hello"); + PT("CType"); cscope_debug_print(scope); cscope_enter(scope); PV("a"); PV("yay"); PV("world"); + PT("CType"); cscope_debug_print(scope); cscope_exit(scope); cscope_debug_print(scope); -- cgit v1.2.3