+static unsigned FunctionModifierFlags (void)
+/* Parse __fastcall__, __near__ and __far__ and return the matching FD_ flags */
+{
+ /* Read the flags */
+ unsigned Flags = FD_NONE;
+ while (CurTok.Tok == TOK_FASTCALL || CurTok.Tok == TOK_NEAR || CurTok.Tok == TOK_FAR) {
+
+ /* Get the flag bit for the next token */
+ unsigned F = FD_NONE;
+ switch (CurTok.Tok) {
+ case TOK_FASTCALL: F = FD_FASTCALL; break;
+ case TOK_NEAR: F = FD_NEAR; break;
+ case TOK_FAR: F = FD_FAR; break;
+ default: Internal ("Unexpected token: %d", CurTok.Tok);
+ }
+
+ /* Remember the flag for this modifier */
+ if (Flags & F) {
+ Error ("Duplicate modifier");
+ }
+ Flags |= F;
+
+ /* Skip the token */
+ NextToken ();
+ }
+
+ /* Sanity check */
+ if ((Flags & (FD_NEAR | FD_FAR)) == (FD_NEAR | FD_FAR)) {
+ Error ("Cannot specify both, `__near__' and `__far__' modifiers");
+ Flags &= ~(FD_NEAR | FD_FAR);
+ }
+
+ /* Return the flags read */
+ return Flags;
+}
+
+
+
+static void ApplyFunctionModifiers (type* T, unsigned Flags)
+/* Apply a set of function modifier flags to a function */
+{
+ /* Get the function descriptor */
+ FuncDesc* F = GetFuncDesc (T);
+
+ /* Special check for __fastcall__ */
+ if ((Flags & FD_FASTCALL) != 0 && IsVariadicFunc (T)) {
+ Error ("Cannot apply `__fastcall__' to functions with "
+ "variable parameter list");
+ Flags &= ~FD_FASTCALL;
+ }
+
+ /* Remove the default function address size modifiers */
+ F->Flags &= ~(FD_NEAR | FD_FAR);
+
+ /* Add the new modifers */
+ F->Flags |= Flags;
+}
+
+
+