Handle -fno-syntax-only.
[cparser] / type.c
diff --git a/type.c b/type.c
index 37893b9..bf0cf49 100644 (file)
--- a/type.c
+++ b/type.c
@@ -311,12 +311,8 @@ static void print_function_type_post(const function_type_t *type,
                                      const scope_t *scope, bool top)
 {
        intern_print_type_post(type->return_type, false);
-       /* don't emit braces if we're the toplevel type... */
-       if (!top)
-               fputc(')', out);
 
        fputc('(', out);
-
        bool first = true;
        if (scope == NULL) {
                function_parameter_t *parameter = type->parameters;
@@ -352,6 +348,10 @@ static void print_function_type_post(const function_type_t *type,
                fputs("void", out);
        }
        fputc(')', out);
+
+       /* don't emit braces if we're the toplevel type... */
+       if (!top)
+               fputc(')', out);
 }
 
 /**
@@ -558,6 +558,7 @@ static void intern_print_type_pre(const type_t *const type, const bool top)
        switch(type->kind) {
        case TYPE_ERROR:
                fputs("<error>", out);
+               return;
        case TYPE_INVALID:
                fputs("<invalid>", out);
                return;
@@ -774,6 +775,18 @@ bool is_type_integer(const type_t *type)
        return test_atomic_type_flag(type->atomic.akind, ATOMIC_TYPE_FLAG_INTEGER);
 }
 
+/**
+ * Returns true if the given type is an enum type.
+ *
+ * @param type  The type to check.
+ * @return True if type is an enum type.
+ */
+bool is_type_enum(const type_t *type)
+{
+       assert(!is_typeref(type));
+       return type->kind == TYPE_ENUM;
+}
+
 /**
  * Returns true if the given type is an floating point type.
  *
@@ -837,6 +850,12 @@ bool is_type_arithmetic(const type_t *type)
        }
 }
 
+/**
+ * Returns true if the given type is an integer or float type.
+ *
+ * @param type  The type to check.
+ * @return True if type is an integer or float type.
+ */
 bool is_type_real(const type_t *type)
 {
        /* 6.2.5.17 */