OSDN Git Service

* cpphash.h (struct cpp_buffer): Move saved_flags from cpp_reader.
authorneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 1 Feb 2001 19:13:53 +0000 (19:13 +0000)
committerneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 1 Feb 2001 19:13:53 +0000 (19:13 +0000)
        * cpplex.c (_cpp_lex_token): New token picks up the saved flags,
        and AVOID_LPASTE is cleared on meeting an unescaped newline.
        * cppmacro.c (builtin_macro): Set builtin flags here.
        (paste_all_tokens): Preserve AVOID_LPASTE on pasted token.
        (replace_args): Clarify intent.
        (cpp_get_token): Macro expansion tokens get the saved flags.
        Update.
        * cppmain.c (scan_buffer): Remove now-redundant print.printed
        check.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39393 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cpphash.h
gcc/cpplex.c
gcc/cppmacro.c
gcc/cppmain.c

index 509d862..a9fe795 100644 (file)
@@ -1,3 +1,16 @@
+2001-02-01  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+        * cpphash.h (struct cpp_buffer): Move saved_flags from cpp_reader.
+        * cpplex.c (_cpp_lex_token): New token picks up the saved flags,
+        and AVOID_LPASTE is cleared on meeting an unescaped newline.
+        * cppmacro.c (builtin_macro): Set builtin flags here.
+        (paste_all_tokens): Preserve AVOID_LPASTE on pasted token.
+        (replace_args): Clarify intent.
+        (cpp_get_token): Macro expansion tokens get the saved flags.
+        Update.
+        * cppmain.c (scan_buffer): Remove now-redundant print.printed
+        check.
+
 2001-02-01  Jeffrey Oldham  <oldham@codesourcery.com>
 
        * config/mips/iris6.h (SUPPORTS_INIT_PRIORITY): Reverse change of
index 6874c21..77c80cd 100644 (file)
@@ -194,6 +194,9 @@ struct cpp_buffer
   /* Line number at line_base (above). */
   unsigned int lineno;
 
+  /* Contains PREV_WHITE and/or AVOID_LPASTE.  */
+  unsigned char saved_flags;
+
   /* Because of the way the lexer works, -Wtrigraphs can sometimes
      warn twice for the same trigraph.  This helps prevent that.  */
   const unsigned char *last_Wtrigraphs;
@@ -331,9 +334,6 @@ struct cpp_reader
   /* We're printed a warning recommending against using #import.  */
   unsigned char import_warning;
 
-  /* Used to flag the token after a paste AVOID_LPASTE.  */
-  unsigned char saved_flags;
-
   /* True after cpp_start_read completes.  Used to inhibit some
      warnings while parsing the command line.  */
   unsigned char done_initializing;
index f9431f8..3ff23b4 100644 (file)
@@ -857,7 +857,8 @@ _cpp_lex_token (pfile, result)
  done_directive:
   buffer = pfile->buffer;
   pfile->state.next_bol = 0;
-  result->flags = 0;
+  result->flags = buffer->saved_flags;
+  buffer->saved_flags = 0;
  next_char:
   pfile->lexer_pos.line = buffer->lineno;
  next_char2:
@@ -899,7 +900,7 @@ _cpp_lex_token (pfile, result)
          /* This is a new line, so clear any white space flag.
             Newlines in arguments are white space (6.10.3.10);
             parse_arg takes care of that.  */
-         result->flags &= ~PREV_WHITE;
+         result->flags &= ~(PREV_WHITE | AVOID_LPASTE);
          goto next_char;
        }
 
@@ -1196,7 +1197,7 @@ _cpp_lex_token (pfile, result)
 
              /* Get whitespace right - newline_in_args sets it.  */
              if (pfile->lexer_pos.col == 1)
-               result->flags &= ~PREV_WHITE;
+               result->flags &= ~(PREV_WHITE | AVOID_LPASTE);
            }
          else
            {
index 2d4663d..afe60dc 100644 (file)
@@ -146,6 +146,7 @@ builtin_macro (pfile, token)
      cpp_reader *pfile;
      cpp_token *token;
 {
+  unsigned char flags = ((token->flags & PREV_WHITE) | AVOID_LPASTE);
   cpp_hashnode *node = token->val.node;
 
   switch (node->value.builtin)
@@ -219,6 +220,8 @@ builtin_macro (pfile, token)
       cpp_ice (pfile, "invalid builtin macro \"%s\"", node->name);
       break;
     }
+
+  token->flags = flags;
 }
 
 /* Used by cpperror.c to obtain the correct line and column to report
@@ -458,7 +461,7 @@ paste_all_tokens (pfile, lhs)
   /* The pasted token has the PREV_WHITE flag of the LHS, is no longer
      PASTE_LEFT, and is subject to macro expansion.  */
   lhs->flags &= ~(PREV_WHITE | PASTE_LEFT | NO_EXPAND);
-  lhs->flags |= orig_flags & PREV_WHITE;
+  lhs->flags |= orig_flags & (PREV_WHITE | AVOID_LPASTE);
 }
 
 /* Reads the unexpanded tokens of a macro argument into ARG.  VAR_ARGS
@@ -798,11 +801,11 @@ replace_args (pfile, macro, args, list)
            /* The first token gets PREV_WHITE of the CPP_MACRO_ARG.  */
            dest->flags &= ~PREV_WHITE;
            dest->flags |= src->flags & PREV_WHITE;
+           dest->flags |= AVOID_LPASTE;
 
            /* The last token gets the PASTE_LEFT of the CPP_MACRO_ARG.  */
            dest[count - 1].flags |= src->flags & PASTE_LEFT;
 
-           dest[0].flags |= AVOID_LPASTE;
            dest += count;
          }
 
@@ -906,10 +909,6 @@ cpp_get_token (pfile, token)
      cpp_reader *pfile;
      cpp_token *token;
 {
-  unsigned char flags = pfile->saved_flags;
-
-  pfile->saved_flags = 0;
-
   for (;;)
     {
       cpp_context *context = pfile->context;
@@ -922,11 +921,13 @@ cpp_get_token (pfile, token)
       else if (context->list.first != context->list.limit)
        {
          *token = *context->list.first++;
+         token->flags |= pfile->buffer->saved_flags;
+         pfile->buffer->saved_flags = 0;
          /* PASTE_LEFT tokens can only appear in macro expansions.  */
          if (token->flags & PASTE_LEFT)
            {
              paste_all_tokens (pfile, token);
-             pfile->saved_flags = AVOID_LPASTE;
+             pfile->buffer->saved_flags = AVOID_LPASTE;
            }
        }
       else
@@ -934,7 +935,7 @@ cpp_get_token (pfile, token)
          if (context->macro)
            {
              /* Avoid accidental paste at the end of a macro.  */
-             flags |= AVOID_LPASTE;
+             pfile->buffer->saved_flags |= AVOID_LPASTE;
              _cpp_pop_context (pfile);
              continue;
            }
@@ -944,8 +945,6 @@ cpp_get_token (pfile, token)
          return;
        }
 
-      token->flags |= flags;
-      flags = 0;
       if (token->type != CPP_NAME)
        break;
 
@@ -959,20 +958,21 @@ cpp_get_token (pfile, token)
          /* Macros invalidate controlling macros.  */
          pfile->mi_state = MI_FAILED;
 
-         /* Remember PREV_WHITE and avoid an accidental paste.  */
-         flags = (token->flags & PREV_WHITE) | AVOID_LPASTE;
-
          if (node->flags & NODE_BUILTIN)
            {
              builtin_macro (pfile, token);
-             token->flags = flags;
              break;
            }
 
          if (node->value.macro->disabled)
            token->flags |= NO_EXPAND;
          else if (enter_macro_context (pfile, node))
-           continue;
+           {
+             /* Pass AVOID_LPASTE and our PREV_WHITE to next token.  */
+             pfile->buffer->saved_flags = ((token->flags & PREV_WHITE)
+                                           | AVOID_LPASTE);
+             continue;
+           }
        }
 
       /* Don't interpret _Pragma within directives.  The standard is
index 13bbbdd..a68d19c 100644 (file)
@@ -234,8 +234,7 @@ scan_buffer (pfile)
                    putc (' ', print.outf);
                }
            }
-         else if (print.printed
-                  && (token->flags & (PREV_WHITE | AVOID_LPASTE))
+         else if ((token->flags & (PREV_WHITE | AVOID_LPASTE))
                       == AVOID_LPASTE
                   && cpp_avoid_paste (pfile, &tokens[1 - index], token))
            token->flags |= PREV_WHITE;