This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch for gas (mri mode).


Ian Lance Taylor wrote:

>    Date: Mon, 20 Sep 1999 13:41:55 -0400
>    From: Vladimir Makarov <vmakarov@tootie.to.cygnus.com>
>
>    The following patch is relative to net binutils repository.  Please,
>    approve it or not.  Without the patch, the assembler code likes the
>    following results in assembler crash because in MRI mode the assembler
>    does not define NARG, but in non-MRI mode the assembler expects that
>    NARG is defined.
>
> That's backward: NARG is defined and expected to exist in MRI mode.
>
> If we think that a macro defined in MRI mode should operate as an
> MRI-style macro, then quite a few more instances of macro_mri need to
> change.  In fact, we probably need to push and pop the global variable
> flag_mri during the macro expansion.
>
> If we just want to fix the particular problem at hand, I think it
> would be clearer to simply check the result of hash_find for NULL,
> rather than consider a macro to be in MRI mode or not.
>

Ian, I thought about this solution.  I've chosen the previous solution.  I
believed that it is clearer because it says clearly about the situation of
usage of macro defined in mri mode and used in non-macro mode (and vise
versa).  It could be useful for anyone who will add code (e.g. new implicit
args) in order to miss the situation because he/she will see new member in
the struct macro.  It could be safer because if something is wrong with the
code with implicit definition of NARG, we will miss the bug because we 'll
think that is defined in mri mode.  Now I see that there are many awkward
situations with .mri usage (e.g. treatment of usage of .mri in macros
themselves).

So, now I'd prefer the simple solution.  Here the new patch is.  Please,
approve it or not.


1999-09-20  Vladimir Makarov  <vmakarov@tootie.to.cygnus.com>

        * macro.c (macro_expand): Expand NARG only if it is defined.

Index: macro.c
===================================================================
RCS file: /cvs/binutils/binutils/gas/macro.c,v
retrieving revision 1.2
diff -c -p -r1.2 macro.c
*** macro.c     1999/06/03 00:23:27     1.2
--- macro.c     1999/09/20 19:37:52
*************** macro_expand (idx, in, m, out, comment_c
*** 1063,1071 ****
        sb_reset (&t);
        sb_add_string (&t, macro_strip_at ? "$NARG" : "NARG");
        ptr = (formal_entry *) hash_find (m->formal_hash, sb_terminate
(&t));
!       sb_reset (&ptr->actual);
!       sprintf (buffer, "%d", narg);
!       sb_add_string (&ptr->actual, buffer);
      }

    err = macro_expand_body (&m->sub, out, m->formals, m->formal_hash,
--- 1063,1075 ----
        sb_reset (&t);
        sb_add_string (&t, macro_strip_at ? "$NARG" : "NARG");
        ptr = (formal_entry *) hash_find (m->formal_hash, sb_terminate
(&t));
!       /* ptr == NULL means that macro is defined not in mri mode. */
!       if (ptr != NULL)
!       {
!         sb_reset (&ptr->actual);
!         sprintf (buffer, "%d", narg);
!         sb_add_string (&ptr->actual, buffer);
!       }
      }

    err = macro_expand_body (&m->sub, out, m->formals, m->formal_hash,



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]