]> git.sur5r.net Git - cc65/commitdiff
Made cc65 properly test calling conventions when it compares forward declarations...
authorGreg King <gregdk@users.sf.net>
Sun, 24 May 2015 22:31:50 +0000 (18:31 -0400)
committerGreg King <gregdk@users.sf.net>
Sun, 24 May 2015 22:31:50 +0000 (18:31 -0400)
src/cc65/declare.c
src/cc65/typecmp.c

index 060a6756dc84f9126710aeb07d3017c56ced9a43..1630848350892bafc71df8006490d3720c8e35c9 100644 (file)
@@ -1455,7 +1455,7 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode)
 
             /* We cannot specify fastcall for variadic functions */
             if ((F->Flags & FD_VARIADIC) && (Qualifiers & T_QUAL_FASTCALL)) {
-                Error ("Variadic functions cannot be `__fastcall__'");
+                Error ("Variadic functions cannot be __fastcall__");
                 Qualifiers &= ~T_QUAL_FASTCALL;
             }
 
index 8025f4efeaa972883a9f09bcd90a055cb934116a..673dfa163b97e19792097e4e9f77cb2a29604978 100644 (file)
@@ -246,6 +246,19 @@ static void DoCompare (const Type* lhs, const Type* rhs, typecmp_t* Result)
                 return;
             }
         }
+
+        if (LeftType == T_TYPE_FUNC) {
+            /* If a calling convention wasn't set explicitly,
+            ** then assume the default one.
+            */
+            if ((LeftQual & T_QUAL_CCONV) == T_QUAL_NONE) {
+                LeftQual |= (AutoCDecl || IsVariadicFunc (lhs)) ? T_QUAL_CDECL : T_QUAL_FASTCALL;
+            }
+            if ((RightQual & T_QUAL_CCONV) == T_QUAL_NONE) {
+                RightQual |= (AutoCDecl || IsVariadicFunc (rhs)) ? T_QUAL_CDECL : T_QUAL_FASTCALL;
+            }
+        }
+
         if (LeftQual != RightQual) {
             /* On the first indirection level, different qualifiers mean
             ** that the types still are compatible. On the second level,
@@ -272,23 +285,7 @@ static void DoCompare (const Type* lhs, const Type* rhs, typecmp_t* Result)
                         SetResult (Result, TC_STRICT_COMPATIBLE);
                     }
 
-                    if (LeftType != T_TYPE_FUNC) {
-                        break;
-                    }
-
-                    /* If a calling convention wasn't set explicitly,
-                    ** then assume the default one.
-                    */
-                    LeftQual &= T_QUAL_CCONV;
-                    if (LeftQual == T_QUAL_NONE) {
-                        LeftQual = (AutoCDecl || IsVariadicFunc (lhs)) ? T_QUAL_CDECL : T_QUAL_FASTCALL;
-                    }
-                    RightQual &= T_QUAL_CCONV;
-                    if (RightQual == T_QUAL_NONE) {
-                        RightQual = (AutoCDecl || IsVariadicFunc (rhs)) ? T_QUAL_CDECL : T_QUAL_FASTCALL;
-                    }
-
-                    if (LeftQual == RightQual) {
+                    if (LeftType != T_TYPE_FUNC || (LeftQual & T_QUAL_CCONV) == (RightQual & T_QUAL_CCONV)) {
                         break;
                     }
                     /* else fall through */