OSDN Git Service

* calls.c (expand_call): Convert structure_value_addr to Pmode if
[pf3gnuchains/gcc-fork.git] / gcc / cpplex.c
index c9c0641..a79bedd 100644 (file)
@@ -63,6 +63,7 @@ static void save_comment PARAMS ((cpp_reader *, cpp_token *, const uchar *,
                                  cppchar_t));
 static void create_literal PARAMS ((cpp_reader *, cpp_token *, const uchar *,
                                    unsigned int, enum cpp_ttype));
+static bool warn_in_comment PARAMS ((cpp_reader *, _cpp_line_note *));
 static int name_p PARAMS ((cpp_reader *, const cpp_string *));
 static cppchar_t maybe_read_ucn PARAMS ((cpp_reader *, const uchar **));
 static tokenrun *next_tokenrun PARAMS ((tokenrun *));
@@ -180,6 +181,36 @@ _cpp_clean_line (pfile)
   buffer->next_line = s + 1;
 }
 
+/* Return true if the trigraph indicated by NOTE should be warned
+   about in a comment.  */
+static bool
+warn_in_comment (pfile, note)
+     cpp_reader *pfile;
+     _cpp_line_note *note;
+{
+  const uchar *p;
+
+  /* Within comments we don't warn about trigraphs, unless the
+     trigraph forms an escaped newline, as that may change
+     behaviour.  */
+  if (note->type != '/')
+    return false;
+
+  /* If -trigraphs, then this was an escaped newline iff the next note
+     is coincident.  */
+  if (CPP_OPTION (pfile, trigraphs))
+    return note[1].pos == note->pos;
+
+  /* Otherwise, see if this forms an escaped newline.  */
+  p = note->pos + 3;
+  while (is_nvspace (*p))
+    p++;
+
+  /* There might have been escaped newlines between the trigraph and the
+     newline we found.  Hence the position test.  */
+  return (*p == '\n' && p < note[1].pos);
+}
+
 /* Process the notes created by add_line_note as far as the current
    location.  */
 void
@@ -219,7 +250,8 @@ _cpp_process_line_notes (pfile, in_comment)
        }
       else if (_cpp_trigraph_map[note->type])
        {
-         if (!in_comment && CPP_OPTION (pfile, warn_trigraphs))
+         if (CPP_OPTION (pfile, warn_trigraphs)
+             && (!in_comment || warn_in_comment (pfile, note)))
            {
              if (CPP_OPTION (pfile, trigraphs))
                cpp_error_with_line (pfile, DL_WARNING, pfile->line, col,
@@ -284,6 +316,7 @@ _cpp_skip_block_comment (pfile)
        }
     }
 
+  _cpp_process_line_notes (pfile, true);
   return false;
 }
 
@@ -369,11 +402,9 @@ forms_identifier_p (pfile, first)
        return false;
 
       buffer->cur++;
-      if (CPP_PEDANTIC (pfile)
-         && !pfile->state.skipping
-         && !pfile->warned_dollar)
+      if (pfile->warn_dollars && !pfile->state.skipping)
        {
-         pfile->warned_dollar = true;
+         pfile->warn_dollars = false;
          cpp_error (pfile, DL_PEDWARN, "'$' in identifier or number");
        }
 
@@ -1094,8 +1125,8 @@ _cpp_lex_direct (pfile)
   return result;
 }
 
-/* An upper bound on the number of bytes needed to spell TOKEN,
-   including preceding whitespace.  */
+/* An upper bound on the number of bytes needed to spell TOKEN.
+   Does not include preceding whitespace.  */
 unsigned int
 cpp_token_len (token)
      const cpp_token *token;
@@ -1104,12 +1135,12 @@ cpp_token_len (token)
 
   switch (TOKEN_SPELL (token))
     {
-    default:           len = 0;                                break;
+    default:           len = 4;                                break;
     case SPELL_LITERAL:        len = token->val.str.len;               break;
     case SPELL_IDENT:  len = NODE_LEN (token->val.node);       break;
     }
-  /* 1 for whitespace, 4 for comment delimiters.  */
-  return len + 5;
+
+  return len;
 }
 
 /* Write the spelling of a token TOKEN to BUFFER.  The buffer must
@@ -1167,8 +1198,8 @@ unsigned char *
 cpp_token_as_text (pfile, token)
      cpp_reader *pfile;
      const cpp_token *token;
-{
-  unsigned int len = cpp_token_len (token);
+{ 
+  unsigned int len = cpp_token_len (token) + 1;
   unsigned char *start = _cpp_unaligned_alloc (pfile, len), *end;
 
   end = cpp_spell_token (pfile, token, start);