Handle -fno-syntax-only.
[cparser] / type.c
diff --git a/type.c b/type.c
index dfb83e7..bf0cf49 100644 (file)
--- a/type.c
+++ b/type.c
@@ -279,6 +279,23 @@ static void print_function_type_pre(const function_type_t *type, bool top)
 
        intern_print_type_pre(type->return_type, false);
 
+       switch (type->calling_convention) {
+       case CC_CDECL:
+               fputs(" __cdecl ", out);
+               break;
+       case CC_STDCALL:
+               fputs(" __stdcall ", out);
+               break;
+       case CC_FASTCALL:
+               fputs(" __fastcall ", out);
+               break;
+       case CC_THISCALL:
+               fputs(" __thiscall ", out);
+               break;
+       case CC_DEFAULT:
+               break;
+       }
+
        /* don't emit braces if we're the toplevel type... */
        if (!top)
                fputc('(', out);
@@ -294,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;
@@ -335,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);
 }
 
 /**
@@ -541,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;
@@ -757,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.
  *
@@ -820,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 */
@@ -922,6 +958,9 @@ static bool function_types_compatible(const function_type_t *func1,
        if (func1->variadic != func2->variadic)
                return false;
 
+       if (func1->calling_convention != func2->calling_convention)
+               return false;
+
        /* TODO: handling of unspecified parameters not correct yet */
 
        /* all argument types must be compatible */