* app.c (do_scrub_chars): Turn #<line>"file"flags into .linefile.
authorAlexandre Oliva <aoliva@redhat.com>
Fri, 9 Mar 2007 07:14:23 +0000 (07:14 +0000)
committerAlexandre Oliva <aoliva@redhat.com>
Fri, 9 Mar 2007 07:14:23 +0000 (07:14 +0000)
* as.h (new_logical_line_flags): New.
* input-scrub.c (new_logical_line): Turned into wrapper for...
(new_logical_line_flags): this.  Handle flags.
* read.c (potable): Add linefile.  Adjust appline argument.
(s_app_file): Fake .appfiles no more.
(s_app_line): For .linefile, accept file name and flags.

gas/ChangeLog
gas/app.c
gas/as.h
gas/input-scrub.c
gas/read.c

index 608be5d3b8ba6f389ba3d3ebf4371728342462ea..bc99c435e9ad8314663647975bc2d752ab1af614 100644 (file)
@@ -1,3 +1,13 @@
+2007-03-09  Alexandre Oliva  <aoliva@redhat.com>
+
+       * app.c (do_scrub_chars): Turn #<line>"file"flags into .linefile.
+       * as.h (new_logical_line_flags): New.
+       * input-scrub.c (new_logical_line): Turned into wrapper for...
+       (new_logical_line_flags): this.  Handle flags.
+       * read.c (potable): Add linefile.  Adjust appline argument.
+       (s_app_file): Fake .appfiles no more.
+       (s_app_line): For .linefile, accept file name and flags.
+
 2007-03-08  Alan Modra  <amodra@bigpond.net.au>
 
        * symbols.c (symbol_relc_make_sym): Comment typo fixes.
index b40411537088c538c5e82d3a3f52c8bb2b0efedd..e6b39d612132a0fa93540a1e6fdc266d7076fb3a 100644 (file)
--- a/gas/app.c
+++ b/gas/app.c
@@ -1,6 +1,6 @@
 /* This is the Assembler Pre-Processor
    Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2006
+   1999, 2000, 2001, 2002, 2003, 2006, 2007
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
    02110-1301, USA.  */
 
 /* Modified by Allen Wirfs-Brock, Instantiations Inc 2/90.  */
-/* App, the assembler pre-processor.  This pre-processor strips out excess
-   spaces, turns single-quoted characters into a decimal constant, and turns
-   # <number> <filename> <garbage> into a .line <number>\n.file <filename>
-   pair.  This needs better error-handling.  */
+/* App, the assembler pre-processor.  This pre-processor strips out
+   excess spaces, turns single-quoted characters into a decimal
+   constant, and turns the # in # <number> <filename> <garbage> into a
+   .linefile.  This needs better error-handling.  */
 
 #include "as.h"
 
@@ -351,10 +351,10 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
          1: After first whitespace on line (flush more white)
          2: After first non-white (opcode) on line (keep 1white)
          3: after second white on line (into operands) (flush white)
-         4: after putting out a .line, put out digits
+         4: after putting out a .linefile, put out digits
          5: parsing a string, then go to old-state
          6: putting out \ escape in a "d string.
-         7: After putting out a .appfile, put out string.
+         7: no longer used
          8: After putting out a .appfile string, flush until newline.
          9: After seeing symbol char in state 3 (keep 1white after symchar)
         10: After seeing whitespace in state 9 (keep white before symchar)
@@ -510,14 +510,11 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
                ch = GET ();
              if (ch == '"')
                {
-                 UNGET (ch);
-                 if (scrub_m68k_mri)
-                   out_string = "\n\tappfile ";
-                 else
-                   out_string = "\n\t.appfile ";
-                 old_state = 7;
-                 state = -1;
-                 PUT (*out_string++);
+                 PUT (' ');
+                 PUT (ch);
+                 quotechar = ch;
+                 state = 5;
+                 old_state = 8;
                }
              else
                {
@@ -638,22 +635,14 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
          PUT (ch);
          continue;
 
-       case 7:
-         ch = GET ();
-         quotechar = ch;
-         state = 5;
-         old_state = 8;
-         PUT (ch);
-         continue;
-
        case 8:
          do
-           ch = GET ();
-         while (ch != '\n' && ch != EOF);
-         if (ch == EOF)
-           goto fromeof;
+           if ((ch = GET ()) == EOF)
+             goto fromeof;
+           else
+             PUT (ch);
+         while (ch != '\n');
          state = 0;
-         PUT (ch);
          continue;
 
 #ifdef DOUBLEBAR_PARALLEL
@@ -1196,9 +1185,9 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
              old_state = 4;
              state = -1;
              if (scrub_m68k_mri)
-               out_string = "\tappline ";
+               out_string = "\tlinefile ";
              else
-               out_string = "\t.appline ";
+               out_string = "\t.linefile ";
              PUT (*out_string++);
              break;
            }
index 3682eb1c8c2e3c72f8bdbc23bb9aeda0ce0d81fa..e73180b1908b05646bd938769892b58c48c02e0b 100644 (file)
--- a/gas/as.h
+++ b/gas/as.h
@@ -550,6 +550,7 @@ void   input_scrub_begin (void);
 void   input_scrub_close (void);
 void   input_scrub_end (void);
 int    new_logical_line (char *, int);
+int    new_logical_line_flags (char *, int, int);
 void   subsegs_begin (void);
 void   subseg_change (segT, int);
 segT   subseg_new (const char *, subsegT);
index 9efea1100e2a68c004c087f93fa80d9235e4e5b5..5698a6dc22a2d1225ae6c01d0fd42165a284bcc1 100644 (file)
@@ -1,6 +1,6 @@
 /* input_scrub.c - Break up input buffers into whole numbers of lines.
    Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   2000, 2001, 2003, 2006
+   2000, 2001, 2003, 2006, 2007
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -435,13 +435,34 @@ bump_line_counters (void)
    Returns nonzero if the filename actually changes.  */
 
 int
-new_logical_line (char *fname, /* DON'T destroy it!  We point to it!  */
-                 int line_number)
+new_logical_line_flags (char *fname, /* DON'T destroy it!  We point to it!  */
+                       int line_number,
+                       int flags)
 {
+  switch (flags)
+    {
+    case 0:
+      break;
+    case 1:
+      if (line_number != -1)
+       abort ();
+      break;
+    case 1 << 1:
+    case 1 << 2:
+      /* FIXME: we could check that include nesting is correct.  */
+      break;
+    default:
+      abort ();
+    }
+
   if (line_number >= 0)
     logical_input_line = line_number;
-  else if (line_number == -2 && logical_input_line > 0)
-    --logical_input_line;
+  else if (line_number == -1 && fname && !*fname && (flags & (1 << 2)))
+    {
+      logical_input_file = physical_input_file;
+      logical_input_line = physical_input_line;
+      fname = NULL;
+    }
 
   if (fname
       && (logical_input_file == NULL
@@ -453,6 +474,13 @@ new_logical_line (char *fname, /* DON'T destroy it!  We point to it!  */
   else
     return 0;
 }
+
+int
+new_logical_line (char *fname, int line_number)
+{
+  return new_logical_line_flags (fname, line_number, 0);
+}
+
 \f
 /* Return the current file name and line number.
    namep should be char * const *, but there are compilers which screw
index 5d7a0d2d2254098f47791c8c3c47c1a46675db3d..97a2ab26ec8dd603e43b4b5536a486e122328690 100644 (file)
@@ -1,6 +1,6 @@
 /* read.c - read a source file -
    Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
    Free Software Foundation, Inc.
 
 This file is part of GAS, the GNU Assembler.
@@ -329,7 +329,7 @@ static const pseudo_typeS potable[] = {
 /* extend  */
   {"extern", s_ignore, 0},     /* We treat all undef as ext.  */
   {"appfile", s_app_file, 1},
-  {"appline", s_app_line, 0},
+  {"appline", s_app_line, 1},
   {"fail", s_fail, 0},
   {"file", s_app_file, 0},
   {"fill", s_fill, 0},
@@ -364,6 +364,7 @@ static const pseudo_typeS potable[] = {
   {"irepc", s_irp, 1},
   {"lcomm", s_lcomm, 0},
   {"lflags", listing_flags, 0},        /* Listing flags.  */
+  {"linefile", s_app_line, 0},
   {"linkonce", s_linkonce, 0},
   {"list", listing_list, 1},   /* Turn listing on.  */
   {"llen", listing_psize, 1},
@@ -1681,11 +1682,8 @@ s_app_file (int appfile)
   /* Some assemblers tolerate immediately following '"'.  */
   if ((s = demand_copy_string (&length)) != 0)
     {
-      /* If this is a fake .appfile, a fake newline was inserted into
-        the buffer.  Passing -2 to new_logical_line tells it to
-        account for it.  */
       int may_omit
-       = (!new_logical_line (s, appfile ? -2 : -1) && appfile);
+       = (!new_logical_line_flags (s, -1, 1) && appfile);
 
       /* In MRI mode, the preprocessor may have inserted an extraneous
         backquote.  */
@@ -1706,7 +1704,7 @@ s_app_file (int appfile)
    pseudo-ops.  */
 
 void
-s_app_line (int ignore ATTRIBUTE_UNUSED)
+s_app_line (int appline)
 {
   int l;
 
@@ -1727,7 +1725,57 @@ s_app_line (int ignore ATTRIBUTE_UNUSED)
             l + 1);
   else
     {
-      new_logical_line ((char *) NULL, l);
+      int flags = 0;
+      char *file = NULL;
+      int length = 0;
+
+      if (!appline)
+       {
+         file = demand_copy_string (&length);
+
+         if (file)
+           {
+             int this_flag;
+
+             while ((this_flag = get_absolute_expression ()))
+               switch (this_flag)
+                 {
+                   /* From GCC's cpp documentation:
+                      1: start of a new file.
+                      2: returning to a file after having included
+                         another file.
+                      3: following text comes from a system header file.
+                      4: following text should be treated as extern "C".
+
+                      4 is nonsensical for the assembler; 3, we don't
+                      care about, so we ignore it just in case a
+                      system header file is included while
+                      preprocessing assembly.  So 1 and 2 are all we
+                      care about, and they are mutually incompatible.
+                      new_logical_line_flags() demands this.  */
+                 case 1:
+                 case 2:
+                   if (flags && flags != (1 << this_flag))
+                     as_warn (_("incompatible flag %i in line directive"),
+                              this_flag);
+                   else
+                     flags |= 1 << this_flag;
+                   break;
+
+                 case 3:
+                 case 4:
+                   /* We ignore these.  */
+                   break;
+
+                 default:
+                   as_warn (_("unsupported flag %i in line directive"),
+                            this_flag);
+                   break;
+                 }
+           }
+       }
+
+      new_logical_line_flags (file, l, flags);
 #ifdef LISTING
       if (listing)
        listing_source_line (l);
This page took 0.033079 seconds and 4 git commands to generate.