Warn about reference address as bool in condition of ?: and if (), too, not only...
[cparser] / type.c
diff --git a/type.c b/type.c
index 204d6f0..3ab686d 100644 (file)
--- a/type.c
+++ b/type.c
@@ -295,10 +295,19 @@ void print_imaginary_type(const imaginary_type_t *type)
  */
 static void print_function_type_pre(const function_type_t *type, bool top)
 {
-       if (type->linkage != NULL) {
-               fputs("extern \"", out);
-               fputs(type->linkage->string, out);
-               fputs("\" ", out);
+       switch (type->linkage) {
+               case LINKAGE_INVALID:
+                       break;
+
+               case LINKAGE_C:
+                       if (c_mode & _CXX)
+                               fputs("extern \"C\" ",   out);
+                       break;
+
+               case LINKAGE_CXX:
+                       if (!(c_mode & _CXX))
+                               fputs("extern \"C++\" ", out);
+                       break;
        }
 
        print_type_qualifiers(type->base.qualifiers);
@@ -307,25 +316,13 @@ static void print_function_type_pre(const function_type_t *type, bool top)
 
        intern_print_type_pre(type->return_type, false);
 
-#if 0
-       /* TODO: revive with linkage */
-       switch (type->linkage) {
-       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;
+       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;
        }
-#endif
 
        /* don't emit parenthesis if we're the toplevel type... */
        if (!top)
@@ -1040,6 +1037,9 @@ static bool function_types_compatible(const function_type_t *func1,
        if (func1->linkage != func2->linkage)
                return false;
 
+       if (func1->calling_convention != func2->calling_convention)
+               return false;
+
        /* can parameters be compared? */
        if (func1->unspecified_parameters || func2->unspecified_parameters)
                return true;