aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.co.uk>2003-04-20 19:02:53 +0000
committerNeil Booth <neil@gcc.gnu.org>2003-04-20 19:02:53 +0000
commit41c32c985faab94f68575f187800595b95267b4e (patch)
treec45f57bd819d5e743141ff692c7b88dc8f88a50b /gcc
parentc6a2438aaf2ceeb137d21d67b00edf27a92104c0 (diff)
downloadgcc-41c32c985faab94f68575f187800595b95267b4e.zip
gcc-41c32c985faab94f68575f187800595b95267b4e.tar.gz
gcc-41c32c985faab94f68575f187800595b95267b4e.tar.bz2
cpphash.h (NOTE_ESC_NL, [...]): Remove.
* cpphash.h (NOTE_ESC_NL, NOTE_ESC_SPACE_NL, NOTE_TRIGRAPH, NOTE_NEWLINE): Remove. * cpplex.c (_cpp_clean_line, _cpp_process_line_notes): Update to handle new form of line note type. From-SVN: r65860
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/cpphash.h9
-rw-r--r--gcc/cpplex.c51
3 files changed, 35 insertions, 32 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f4e81eb..d5773b0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2003-04-20 Neil Booth <neil@daikokuya.co.uk>
+
+ * cpphash.h (NOTE_ESC_NL, NOTE_ESC_SPACE_NL, NOTE_TRIGRAPH,
+ NOTE_NEWLINE): Remove.
+ * cpplex.c (_cpp_clean_line, _cpp_process_line_notes): Update
+ to handle new form of line note type.
+
2003-04-20 Zack Weinberg <zack@codesourcery.com>
* target.h (encode_section_info): Add new argument carrying
diff --git a/gcc/cpphash.h b/gcc/cpphash.h
index 4eee942..6e17226 100644
--- a/gcc/cpphash.h
+++ b/gcc/cpphash.h
@@ -243,11 +243,10 @@ struct _cpp_line_note
/* Location in the clean line the note refers to. */
const uchar *pos;
- /* Type of note. */
- enum { NOTE_ESC_NL = 0,
- NOTE_ESC_SPACE_NL,
- NOTE_TRIGRAPH,
- NOTE_NEWLINE } type;
+ /* Type of note. The 9 'from' trigraph characters represent those
+ trigraphs, '\\' an escaped newline, ' ' an escaped newline with
+ intervening space, and anything else is invalid. */
+ unsigned int type;
};
/* Represents the contents of a file cpplib has read in. */
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index efb5c06..c148dad 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -148,15 +148,14 @@ _cpp_clean_line (pfile)
if (p == buffer->next_line || p[-1] != '\\')
break;
- add_line_note (buffer, p - 1,
- p != d ? NOTE_ESC_SPACE_NL: NOTE_ESC_NL);
+ add_line_note (buffer, p - 1, p != d ? ' ': '\\');
d = p - 2;
buffer->next_line = p - 1;
}
else if (c == '?' && s[1] == '?' && _cpp_trigraph_map[s[2]])
{
/* Add a note regardless, for the benefit of -Wtrigraphs. */
- add_line_note (buffer, d, NOTE_TRIGRAPH);
+ add_line_note (buffer, d, s[2]);
if (CPP_OPTION (pfile, trigraphs))
{
*d = _cpp_trigraph_map[s[2]];
@@ -178,7 +177,8 @@ _cpp_clean_line (pfile)
}
*d = '\n';
- add_line_note (buffer, d + 1, NOTE_NEWLINE);
+ /* A sentinel note that should never be processed. */
+ add_line_note (buffer, d + 1, '\n');
buffer->next_line = s + 1;
}
@@ -202,32 +202,12 @@ _cpp_process_line_notes (pfile, in_comment)
buffer->cur_note++;
col = CPP_BUF_COLUMN (buffer, note->pos + 1);
- switch (note->type)
+ if (note->type == '\\' || note->type == ' ')
{
- case NOTE_NEWLINE:
- /* This note is a kind of sentinel we should never reach. */
- abort ();
-
- case NOTE_TRIGRAPH:
- if (!in_comment && CPP_OPTION (pfile, warn_trigraphs))
- {
- if (CPP_OPTION (pfile, trigraphs))
- cpp_error_with_line (pfile, DL_WARNING, pfile->line, col,
- "trigraph converted to %c",
- (int) note->pos[0]);
- else
- cpp_error_with_line (pfile, DL_WARNING, pfile->line, col,
- "trigraph ??%c ignored",
- (int) note->pos[2]);
- }
- break;
-
- case NOTE_ESC_SPACE_NL:
- if (!in_comment)
+ if (note->type == ' ' && !in_comment)
cpp_error_with_line (pfile, DL_WARNING, pfile->line, col,
"backslash and newline separated by space");
- /* Fall through... */
- case NOTE_ESC_NL:
+
if (buffer->next_line > buffer->rlimit)
{
cpp_error_with_line (pfile, DL_PEDWARN, pfile->line, col,
@@ -239,6 +219,23 @@ _cpp_process_line_notes (pfile, in_comment)
buffer->line_base = note->pos;
pfile->line++;
}
+ else if (_cpp_trigraph_map[note->type])
+ {
+ if (!in_comment && CPP_OPTION (pfile, warn_trigraphs))
+ {
+ if (CPP_OPTION (pfile, trigraphs))
+ cpp_error_with_line (pfile, DL_WARNING, pfile->line, col,
+ "trigraph ??%c converted to %c",
+ note->type,
+ (int) _cpp_trigraph_map[note->type]);
+ else
+ cpp_error_with_line (pfile, DL_WARNING, pfile->line, col,
+ "trigraph ??%c ignored",
+ note->type);
+ }
+ }
+ else
+ abort ();
}
}