fixed optimzation for Atom
[platform/upstream/binutils.git] / gas / macro.c
index b3e0fd0..d3b4e47 100644 (file)
@@ -1,6 +1,5 @@
 /* macro.c - macro support for gas
-   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2006, 2007, 2008, 2011, 2012 Free Software Foundation, Inc.
+   Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
    Written by Steve and Judy Chamberlain of Cygnus Support,
       sac@cygnus.com
@@ -212,6 +211,28 @@ buffer_and_nest (const char *from, const char *to, sb *ptr,
                  break;
                }
            }
+
+         /* PR gas/16908
+            Apply and discard .linefile directives that appear within
+            the macro.  For long macros, one might want to report the
+            line number information associated with the lines within
+            the macro definition, but we would need more infrastructure
+            to make that happen correctly (e.g. resetting the line
+            number when expanding the macro), and since for short
+            macros we clearly prefer reporting the point of expansion
+            anyway, there's not an obviously better fix here.  */
+         if (strncasecmp (ptr->ptr + i, "linefile", 8) == 0)
+           {
+             char *saved_input_line_pointer = input_line_pointer;
+             char saved_eol_char = ptr->ptr[ptr->len];
+
+             ptr->ptr[ptr->len] = '\0';
+             input_line_pointer = ptr->ptr + i + 8;
+             s_app_line (0);
+             ptr->ptr[ptr->len] = saved_eol_char;
+             input_line_pointer = saved_input_line_pointer;
+             ptr->len = line_start;
+           }
        }
 
       /* Add the original end-of-line char to the end and keep running.  */
@@ -574,9 +595,9 @@ do_formals (macro_entry *macro, size_t idx, sb *in)
       formal_entry *formal = new_formal ();
 
       /* Add a special NARG formal, which macro_expand will set to the
-         number of arguments.  */
+        number of arguments.  */
       /* The same MRI assemblers which treat '@' characters also use
-         the name $NARG.  At least until we find an exception.  */
+        the name $NARG.  At least until we find an exception.  */
       if (macro_strip_at)
        name = "$NARG";
       else
@@ -642,7 +663,7 @@ define_macro (size_t idx, sb *in, sb *label,
 
   macro->formal_count = 0;
   macro->formals = 0;
-  macro->formal_hash = hash_new ();
+  macro->formal_hash = hash_new_sized (7);
 
   idx = sb_skip_white (idx, in);
   if (! buffer_and_nest ("MACRO", "ENDM", &macro->sub, get_line))
@@ -950,13 +971,13 @@ macro_expand_body (sb *in, sb *out, formal_entry *formals,
          if (ptr == NULL)
            {
              /* FIXME: We should really return a warning string here,
-                 but we can't, because the == might be in the MRI
-                 comment field, and, since the nature of the MRI
-                 comment field depends upon the exact instruction
-                 being used, we don't have enough information here to
-                 figure out whether it is or not.  Instead, we leave
-                 the == in place, which should cause a syntax error if
-                 it is not in a comment.  */
+                but we can't, because the == might be in the MRI
+                comment field, and, since the nature of the MRI
+                comment field depends upon the exact instruction
+                being used, we don't have enough information here to
+                figure out whether it is or not.  Instead, we leave
+                the == in place, which should cause a syntax error if
+                it is not in a comment.  */
              sb_add_char (out, '=');
              sb_add_char (out, '=');
              sb_add_sb (out, &t);
@@ -1023,7 +1044,7 @@ macro_expand (size_t idx, sb *in, macro_entry *m, sb *out)
   if (macro_mri)
     {
       /* The macro may be called with an optional qualifier, which may
-         be referred to in the macro body as \0.  */
+        be referred to in the macro body as \0.  */
       if (idx < in->len && in->ptr[idx] == '.')
        {
          /* The Microtec assembler ignores this if followed by a white space.
@@ -1349,7 +1370,7 @@ expand_irp (int irpc, size_t idx, sb *in, sb *out, size_t (*get_line) (sb *))
 
                  if (irpc)
                    in_quotes = ! in_quotes;
-         
+
                  nxt = sb_skip_white (idx + 1, in);
                  if (nxt >= in->len)
                    {