diff options
Diffstat (limited to 'codegen.c')
-rw-r--r-- | codegen.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -145,7 +145,11 @@ const void typedecl(Type *type) { println("typedef char Type_%d ;", type->id); break; case TY_PTR: + // When we recurse, we need to set the type id to 0 because we haven't + // printed it out yet. + type->id = 0; typedecl(type->base); + if (!type->id) type->id = count(); println("typedef Type_%d * Type_%d ;", type->base->id, type->id); break; case TY_FUNC: { @@ -167,7 +171,9 @@ const void typedecl(Type *type) { break; } case TY_ARRAY: + type->id = 0; typedecl(type->base); + if (!type->id) type->id = count(); if (type->array_len == -1) println("typedef Type_%d Type_%d [ ] ;", type->base->id, type->id); else |