C = PrintTypeComp (F, C, T_QUAL_NEAR, "__near__");
C = PrintTypeComp (F, C, T_QUAL_FAR, "__far__");
C = PrintTypeComp (F, C, T_QUAL_FASTCALL, "__fastcall__");
+ C = PrintTypeComp (F, C, T_QUAL_CDECL, "__cdecl__");
/* Signedness. Omit the signedness specifier for long and int */
if ((C & T_MASK_TYPE) != T_TYPE_INT && (C & T_MASK_TYPE) != T_TYPE_LONG) {
if (IsQualFastcall (T)) {
fprintf (F, " __fastcall__");
}
+ if (IsQualCDecl (T)) {
+ fprintf (F, " __cdecl__");
+ }
fprintf (F, " %s (", Name);
/* Parameters */
/* */
/* */
/* */
-/* (C) 1998-2008 Ullrich von Bassewitz */
-/* Roemerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
T_QUAL_FAR = 0x008000,
T_QUAL_ADDRSIZE = T_QUAL_NEAR | T_QUAL_FAR,
T_QUAL_FASTCALL = 0x010000,
- T_MASK_QUAL = 0x01F800,
+ T_QUAL_CDECL = 0x020000,
+ T_QUAL_CCONV = T_QUAL_FASTCALL | T_QUAL_CDECL,
+ T_MASK_QUAL = 0x03F800,
/* Types */
T_CHAR = T_TYPE_CHAR | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_NONE,
# define IsQualFastcall(T) (((T)->C & T_QUAL_FASTCALL) != 0)
#endif
+#if defined(HAVE_INLINE)
+INLINE int IsQualCDecl (const Type* T)
+/* Return true if the given type has a cdecl qualifier */
+{
+ return (T->C & T_QUAL_CDECL) != 0;
+}
+#else
+# define IsQualCDecl(T) (((T)->C & T_QUAL_CDECL) != 0)
+#endif
+
int IsVariadicFunc (const Type* T) attribute ((const));
/* Return true if this is a function type or pointer to function type with
* variable parameter list
/* */
/* */
/* */
-/* (C) 1998-2008 Ullrich von Bassewitz */
-/* Roemerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
}
break;
+ case TOK_CDECL:
+ if (Allowed & T_QUAL_CDECL) {
+ if (Q & T_QUAL_CDECL) {
+ DuplicateQualifier ("cdecl");
+ }
+ Q |= T_QUAL_CDECL;
+ } else {
+ goto Done;
+ }
+ break;
+
default:
goto Done;
Q &= ~T_QUAL_ADDRSIZE;
}
+ /* We cannot have more than one calling convention specifier */
+ switch (Q & T_QUAL_CCONV) {
+
+ case T_QUAL_NONE:
+ case T_QUAL_FASTCALL:
+ case T_QUAL_CDECL:
+ break;
+
+ default:
+ Error ("Cannot specify more than one calling convention qualifier");
+ Q &= ~T_QUAL_CCONV;
+ }
+
/* Return the qualifiers read */
return Q;
}
if (Qualifiers & T_QUAL_FASTCALL) {
Error ("Invalid `__fastcall__' qualifier");
}
+ if (Qualifiers & T_QUAL_CDECL) {
+ Error ("Invalid `__cdecl__' qualifier");
+ }
}
int TokIsFuncSpec (const Token* T)
/* Return true if the token is a function specifier */
{
- return (T->Tok == TOK_INLINE) || (T->Tok == TOK_FASTCALL) ||
- (T->Tok == TOK_NEAR) || (T->Tok == TOK_FAR);
+ return (T->Tok == TOK_INLINE) ||
+ (T->Tok == TOK_FASTCALL) || (T->Tok == TOK_CDECL) ||
+ (T->Tok == TOK_NEAR) || (T->Tok == TOK_FAR);
}