aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.co.uk>2002-06-27 06:01:58 +0000
committerNeil Booth <neil@gcc.gnu.org>2002-06-27 06:01:58 +0000
commit951a07660948ce4c3b048dc7637f5738a9d9d288 (patch)
treeb68bbff6125d07a1cae24355b3075fc5c636bea1 /gcc
parent0647023885b52c9eda290f593432d245f1e30ce3 (diff)
downloadgcc-951a07660948ce4c3b048dc7637f5738a9d9d288.zip
gcc-951a07660948ce4c3b048dc7637f5738a9d9d288.tar.gz
gcc-951a07660948ce4c3b048dc7637f5738a9d9d288.tar.bz2
cpphash.h (_cpp_set_trad_context): Remove.
* cpphash.h (_cpp_set_trad_context): Remove. * cpplib.c (prepare_directive_trad): Do nothing for #define. (cpp_push_buffer, _cpp_pop_buffer): Don't call _cpp_set_trad_context. * cpptrad.c: Update comments. (_cpp_read_logical_line_trad): Let scan_logical_line handle updating the current context. (scan_logical_line): Update the current context. (_cpp_create_trad_definition): Similarly. (_cpp_set_trad_context): Remove. From-SVN: r55022
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/cpphash.h1
-rw-r--r--gcc/cpplib.c10
-rw-r--r--gcc/cpptrad.c78
4 files changed, 45 insertions, 56 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a1a5173..8b4df3f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,17 @@
2002-06-27 Neil Booth <neil@daikokuya.co.uk>
+ * cpphash.h (_cpp_set_trad_context): Remove.
+ * cpplib.c (prepare_directive_trad): Do nothing for #define.
+ (cpp_push_buffer, _cpp_pop_buffer): Don't call _cpp_set_trad_context.
+ * cpptrad.c: Update comments.
+ (_cpp_read_logical_line_trad): Let scan_logical_line handle
+ updating the current context.
+ (scan_logical_line): Update the current context.
+ (_cpp_create_trad_definition): Similarly.
+ (_cpp_set_trad_context): Remove.
+
+2002-06-27 Neil Booth <neil@daikokuya.co.uk>
+
PR preprocessor/7070
* c-lex.c (cb_def_pragma): Don't try to spell CPP_EOF.
diff --git a/gcc/cpphash.h b/gcc/cpphash.h
index ee9a47e..133c9b93 100644
--- a/gcc/cpphash.h
+++ b/gcc/cpphash.h
@@ -529,7 +529,6 @@ extern bool _cpp_read_logical_line_trad PARAMS ((cpp_reader *));
extern void _cpp_overlay_buffer PARAMS ((cpp_reader *pfile, const uchar *,
size_t));
extern void _cpp_remove_overlay PARAMS ((cpp_reader *));
-extern void _cpp_set_trad_context PARAMS ((cpp_reader *));
extern bool _cpp_create_trad_definition PARAMS ((cpp_reader *, cpp_macro *));
extern bool _cpp_expansions_different_trad PARAMS ((const cpp_macro *,
const cpp_macro *));
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index 18e44ba..6bb9f4d 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -284,9 +284,7 @@ static void
prepare_directive_trad (pfile)
cpp_reader *pfile;
{
- if (pfile->directive == &dtable[T_DEFINE])
- CUR (pfile->context) = pfile->buffer->cur;
- else
+ if (pfile->directive != &dtable[T_DEFINE])
{
bool no_expand = (pfile->directive
&& ! (pfile->directive->flags & EXPAND));
@@ -1937,9 +1935,6 @@ cpp_push_buffer (pfile, buffer, len, from_stage3, return_at_eof)
pfile->buffer = new;
- if (CPP_OPTION (pfile, traditional))
- _cpp_set_trad_context (pfile);
-
return new;
}
@@ -1984,9 +1979,6 @@ _cpp_pop_buffer (pfile)
_cpp_maybe_push_include_file (pfile);
}
}
-
- if (pfile->buffer && CPP_OPTION (pfile, traditional))
- _cpp_set_trad_context (pfile);
}
/* Enter all recognised directives in the hash table. */
diff --git a/gcc/cpptrad.c b/gcc/cpptrad.c
index 9bcb915..4d07d52 100644
--- a/gcc/cpptrad.c
+++ b/gcc/cpptrad.c
@@ -23,12 +23,12 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* The replacement text of a function-like macro is stored as a
contiguous sequence of aligned blocks, each representing the text
- between subsequent parameters in that text.
+ between subsequent parameters.
- Each block comprises the length of text contained therein, the
- one-based index of the argument that immediately follows that text,
- and the text itself. The final block in the macro expansion is
- easily recognizable as it has an argument index of zero. */
+ Each block comprises the text between its surrounding parameters,
+ the length of that text, and the one-based index of the following
+ parameter. The final block in the replacement text is easily
+ recognizable as it has an argument index of zero. */
struct block
{
@@ -139,9 +139,9 @@ handle_newline (pfile, cur)
return cur + 1;
}
-/* CUR points to any character in the buffer, not necessarily a
- backslash. Advances CUR until all escaped newlines are skipped,
- and returns the new position.
+/* CUR points to any character in the current context, not necessarily
+ a backslash. Advances CUR until all escaped newlines are skipped,
+ and returns the new position without updating the context.
Warns if a file buffer ends in an escaped newline. */
static const uchar *
@@ -160,9 +160,9 @@ skip_escaped_newlines (pfile, cur)
return cur;
}
-/* CUR points to the asterisk introducing a comment in the input
- buffer. IN_DEFINE is true if we are in the replacement text
- of a macro.
+/* CUR points to the asterisk introducing a comment in the current
+ context. IN_DEFINE is true if we are in the replacement text of a
+ macro.
The asterisk and following comment is copied to the buffer pointed
to by pfile->out.cur, which must be of sufficient size.
@@ -364,31 +364,24 @@ bool
_cpp_read_logical_line_trad (pfile)
cpp_reader *pfile;
{
- cpp_buffer *buffer = pfile->buffer;
-
do
{
- if (buffer->cur == buffer->rlimit)
+ if (pfile->buffer->cur == pfile->buffer->rlimit)
{
bool stop = true;
/* Don't pop the last buffer. */
- if (buffer->prev)
+ if (pfile->buffer->prev)
{
- stop = buffer->return_at_eof;
+ stop = pfile->buffer->return_at_eof;
_cpp_pop_buffer (pfile);
- buffer = pfile->buffer;
}
if (stop)
return false;
}
- CUR (pfile->context) = buffer->cur;
- RLIMIT (pfile->context) = buffer->rlimit;
scan_out_logical_line (pfile, NULL);
- buffer = pfile->buffer;
- buffer->cur = CUR (pfile->context);
}
while (pfile->state.skipping);
@@ -426,9 +419,9 @@ save_argument (macro, offset)
macro->args[macro->argc] = offset;
}
-/* Copies the next logical line in the current buffer to the output
- buffer. The output is guaranteed to terminate with a NUL
- character.
+/* Copies the next logical line in the current buffer (starting at
+ buffer->cur) to the output buffer. The output is guaranteed to
+ terminate with a NUL character. buffer->cur is updated.
If MACRO is non-NULL, then we are scanning the replacement list of
MACRO, and we call save_replacement_text() every time we meet an
@@ -448,6 +441,8 @@ scan_out_logical_line (pfile, macro)
fmacro.buff = NULL;
start_logical_line:
+ CUR (pfile->context) = pfile->buffer->cur;
+ RLIMIT (pfile->context) = pfile->buffer->rlimit;
pfile->out.cur = pfile->out.base;
pfile->out.first_line = pfile->line;
new_context:
@@ -721,6 +716,8 @@ scan_out_logical_line (pfile, macro)
preprocessor lex the next token. */
pfile->buffer->cur = cur;
_cpp_handle_directive (pfile, false /* indented */);
+ /* #include changes pfile->buffer so we need to
+ update the limits of the current context. */
goto start_logical_line;
}
}
@@ -759,7 +756,7 @@ scan_out_logical_line (pfile, macro)
done:
out[-1] = '\0';
- CUR (context) = cur;
+ pfile->buffer->cur = cur;
pfile->out.cur = out - 1;
if (fmacro.buff)
_cpp_release_buff (pfile, fmacro.buff);
@@ -1072,11 +1069,17 @@ _cpp_create_trad_definition (pfile, macro)
{
const uchar *cur;
uchar *limit;
+ cpp_context *context = pfile->context;
- CUR (pfile->context) = pfile->buffer->cur;
+ /* The context has not been set up for command line defines, and CUR
+ has not been updated for the macro name for in-file defines. */
+ pfile->out.cur = pfile->out.base;
+ CUR (context) = pfile->buffer->cur;
+ RLIMIT (context) = pfile->buffer->rlimit;
+ check_output_buffer (pfile, RLIMIT (context) - CUR (context));
/* Is this a function-like macro? */
- if (* CUR (pfile->context) == '(')
+ if (* CUR (context) == '(')
{
/* Setting macro to NULL indicates an error occurred, and
prevents unnecessary work in scan_out_logical_line. */
@@ -1092,8 +1095,8 @@ _cpp_create_trad_definition (pfile, macro)
}
/* Skip leading whitespace in the replacement text. */
- CUR (pfile->context)
- = skip_whitespace (pfile, CUR (pfile->context),
+ pfile->buffer->cur
+ = skip_whitespace (pfile, CUR (context),
CPP_OPTION (pfile, discard_comments_in_macro_exp));
pfile->state.prevent_expansion++;
@@ -1202,20 +1205,3 @@ _cpp_expansions_different_trad (macro1, macro2)
free (p1);
return mismatch;
}
-
-/* Prepare to be able to scan the current buffer. */
-void
-_cpp_set_trad_context (pfile)
- cpp_reader *pfile;
-{
- cpp_buffer *buffer = pfile->buffer;
- cpp_context *context = pfile->context;
-
- if (pfile->context->prev)
- abort ();
-
- pfile->out.cur = pfile->out.base;
- CUR (context) = buffer->cur;
- RLIMIT (context) = buffer->rlimit;
- check_output_buffer (pfile, RLIMIT (context) - CUR (context));
-}