From: Greg King Date: Sun, 24 May 2015 22:31:50 +0000 (-0400) Subject: Made cc65 properly test calling conventions when it compares forward declarations... X-Git-Tag: V2.15~3^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bbb6f89731ccc54bffcc811e9405192f16cbbd89;p=cc65 Made cc65 properly test calling conventions when it compares forward declarations to function definitions. --- diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 060a6756d..163084835 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -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; } diff --git a/src/cc65/typecmp.c b/src/cc65/typecmp.c index 8025f4efe..673dfa163 100644 --- a/src/cc65/typecmp.c +++ b/src/cc65/typecmp.c @@ -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 */