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 d089e25..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);