Open uucidl opened 6 years ago
My alternative fix was to let type_to_cdecl
not emit the redundant const:
diff --git a/deps/bitwise/ion/gen.c b/deps/bitwise/ion/gen.c
index 16c18fe..c729b05 100644
--- a/deps/bitwise/ion/gen.c
+++ b/deps/bitwise/ion/gen.c
@@ -216,6 +216,9 @@ char *type_to_cdecl(Type *type, const char *str) {
case TYPE_PTR:
return type_to_cdecl(type->base, cdecl_paren(strf("*%s", str), *str));
case TYPE_CONST:
+ if (type->base->kind == TYPE_ARRAY) {
+ return type_to_cdecl(type->base, str);
+ }
return type_to_cdecl(type->base, strf("const %s", cdecl_paren(str, *str)));
case TYPE_ARRAY:
if (type->num_elems == 0) {
With the following:
Then when TypeInfo gets written, ion generates:
the
int (const [3])
is not parsed as a valid type expressionSomehow the type entry seems invalid to me, as all arrays in C are const. So the type info should probably not be generated at all (TYPE_CONST with base TYPE_ARRAY)
type_to_cdecl
could be instrumented to assert that a TYPE_CONST should not be an array