This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
cpplib: line-at-a-time lexing
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: Zack Weinberg <zack at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 9 Sep 2002 15:08:58 +0100
- Subject: cpplib: line-at-a-time lexing
This is about the bare minimum necessary to get cpplib to lex
lines at a time, rather than the current method of lexing the
next token only when it's needed.
This patch is good enough to bootstrap c, objc and c++ without
testsuite regressions. It is still buggy, in that resizing an
internal token array at the wrong time can leave pointers
dangling. The default array sizes are such that this is a rare
occurrence. However, this makes me reluctant to commit it to
the BIB branch; so unless you think it should go in anyway
I'm just posting it as an FYI, Zack.
This patch contains slight lossage w.r.t. #pragma poison:
since we lex a line before interpreting it, things like
_Pragma ("GCC poison foo") foo
no longer complain that "foo" is poisioned since it wasn't when we
lexed it. Also, we used to permit re-poisoning a poisoned identifier,
this now complains about use of a poisoned identifier. I don't think
either of these is a great loss, but the latter can be recreated with
a bit of effort if it's deemed worthwhile (the problem is context
sensitivity: to not warn about being re-poisoned, we need to know
if we're in a #pragma poison when lexing, so this would need a scan
of already-lexed tokens that I've not written. There is a similar issue
with __VA_ARGS__, but I've written the code for that). The former
is not really fixable, but easily worked around by documenting
that #pragma GCC poison only applies from the subsequent line.
I've moved a trad testcase into trad/, and changed the warning on
directives in macro arguments to fire if -std, rather than if
-pedantic, since that seems to be more appropriate.
The patch removes a few nasty features from the current code, but
adds its own share of nasty kludges. Most can go away when the next
stage is finished.
The next stage is macro-expanding a just lexed token line, if
appropriate. This will make many things simpler. For example, the
directive handlers can just take a token line and operate on that,
removing the need for them to be calling cpp_get_token(). The front
ends can get tokens a line at a time rather than individually, as can
the preprocessed output code which could more easily write it to a
buffer for a large speed- up. Further, the baggage of paste-avoidance
tokens could be entirely removed.
Neil.
============================================================
Index: gcc/cpphash.h
--- gcc/cpphash.h 5 Sep 2002 17:46:50 -0000 1.170.4.1
+++ gcc/cpphash.h 9 Sep 2002 13:52:16 -0000
@@ -161,8 +161,8 @@ union utoken
typedef struct tokenrun tokenrun;
struct tokenrun
{
- tokenrun *next, *prev;
- cpp_token *base, *limit;
+ cpp_token *base, *limit; /* Limits of memory block. */
+ cpp_token *end; /* Last token in the run. */
};
/* Accessor macros for struct cpp_context. */
@@ -228,12 +228,6 @@ struct lexer_state
/* Nonzero if we're mid-comment. */
unsigned char lexing_comment;
- /* Nonzero if lexing __VA_ARGS__ is valid. */
- unsigned char va_args_ok;
-
- /* Nonzero if lexing poisoned identifiers is valid. */
- unsigned char poisoned_ok;
-
/* Nonzero to prevent macro expansion. */
unsigned char prevent_expansion;
@@ -288,9 +282,6 @@ struct cpp_buffer
/* Token column position adjustment owing to tabs in whitespace. */
unsigned int col_adjust;
- /* 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;
@@ -357,6 +348,10 @@ struct cpp_reader
/* If in_directive, the directive if known. */
const struct directive *directive;
+ /* Offset of first token in directive. An offset is used since the
+ array may be reallocated. */
+ size_t dir_first;
+
/* The next -include-d file; NULL if they all are done. If it
points to NULL, the last one is in progress, and
_cpp_maybe_push_include_file has yet to restore the line map. */
@@ -370,10 +365,6 @@ struct cpp_reader
/* Lexing. */
cpp_token *cur_token;
tokenrun base_run, *cur_run;
- unsigned int lookaheads;
-
- /* Non-zero prevents the lexer from re-using the token runs. */
- unsigned int keep_tokens;
/* Error counter for exit code. */
unsigned int errors;
@@ -400,6 +391,11 @@ struct cpp_reader
cpp_token avoid_paste;
cpp_token eof;
+ /* If, after the name of a funlike macro, a newly lexed line does
+ not start with a '(', we store the end of the new line here and
+ leave the recorded end unchanged. */
+ cpp_token *saved_end;
+
/* Opaque handle to the dependencies of mkdeps.c. */
struct deps *deps;
@@ -528,19 +524,23 @@ extern bool _cpp_parse_expr PARAMS ((cp
extern struct op *_cpp_expand_op_stack PARAMS ((cpp_reader *));
/* In cpplex.c */
-extern cpp_token *_cpp_temp_token PARAMS ((cpp_reader *));
extern const cpp_token *_cpp_lex_token PARAMS ((cpp_reader *));
-extern cpp_token *_cpp_lex_direct PARAMS ((cpp_reader *));
+extern bool _cpp_lex_direct PARAMS ((cpp_reader *, cpp_token *));
+extern cpp_token *_cpp_temp_token PARAMS ((cpp_reader *));
extern int _cpp_equiv_tokens PARAMS ((const cpp_token *,
const cpp_token *));
extern void _cpp_init_tokenrun PARAMS ((tokenrun *, unsigned int));
+extern void _cpp_lex_line PARAMS ((cpp_reader *, tokenrun *,
+ size_t));
/* In cppinit.c. */
extern void _cpp_maybe_push_include_file PARAMS ((cpp_reader *));
/* In cpplib.c */
+extern bool _cpp_classify_directive
+ PARAMS ((cpp_reader *, const cpp_token *, int));
+extern void _cpp_handle_directive PARAMS ((cpp_reader *));
extern int _cpp_test_assertion PARAMS ((cpp_reader *, unsigned int *));
-extern int _cpp_handle_directive PARAMS ((cpp_reader *, int));
extern void _cpp_define_builtin PARAMS ((cpp_reader *, const char *));
extern void _cpp_do__Pragma PARAMS ((cpp_reader *));
extern void _cpp_init_directives PARAMS ((cpp_reader *));
@@ -549,6 +549,7 @@ extern void _cpp_do_file_change PARAMS (
const char *,
unsigned int, unsigned int));
extern void _cpp_pop_buffer PARAMS ((cpp_reader *));
+extern bool _cpp_variadic_definition_p PARAMS ((cpp_reader *));
/* In cpptrad.c. */
extern bool _cpp_read_logical_line_trad PARAMS ((cpp_reader *));
============================================================
Index: gcc/cppinit.c
--- gcc/cppinit.c 21 Aug 2002 17:07:26 -0000 1.260
+++ gcc/cppinit.c 9 Sep 2002 13:52:17 -0000
@@ -590,7 +590,6 @@ cpp_destroy (pfile)
{
struct search_path *dir, *dirn;
cpp_context *context, *contextn;
- tokenrun *run, *runn;
free_chain (CPP_OPTION (pfile, pending)->include_head);
free (CPP_OPTION (pfile, pending));
@@ -620,13 +619,7 @@ cpp_destroy (pfile)
_cpp_free_buff (pfile->u_buff);
_cpp_free_buff (pfile->free_buffs);
- for (run = &pfile->base_run; run; run = runn)
- {
- runn = run->next;
- free (run->base);
- if (run != &pfile->base_run)
- free (run);
- }
+ free (pfile->base_run.base);
for (dir = CPP_OPTION (pfile, quote_include); dir; dir = dirn)
{
@@ -1013,26 +1006,21 @@ static void
read_original_filename (pfile)
cpp_reader *pfile;
{
- const cpp_token *token, *token1;
+ const cpp_token *token;
/* Lex ahead; if the first tokens are of the form # NUM, then
- process the directive, otherwise back up. */
- token = _cpp_lex_direct (pfile);
+ process the directive. */
+ _cpp_lex_line (pfile, &pfile->base_run, 0);
+ token = pfile->base_run.base;
if (token->type == CPP_HASH)
{
- token1 = _cpp_lex_direct (pfile);
- _cpp_backup_tokens (pfile, 1);
-
- /* If it's a #line directive, handle it. */
- if (token1->type == CPP_NUMBER)
+ _cpp_classify_directive (pfile, token + 1, token->flags & PREV_WHITE);
+ if (token[1].type == CPP_NUMBER)
{
- _cpp_handle_directive (pfile, token->flags & PREV_WHITE);
- return;
+ pfile->dir_first = 2;
+ _cpp_handle_directive (pfile);
}
}
-
- /* Backup as if nothing happened. */
- _cpp_backup_tokens (pfile, 1);
}
/* Handle pending command line options: -D, -U, -A, -imacros and
============================================================
Index: gcc/cpplex.c
--- gcc/cpplex.c 21 Jul 2002 21:35:15 -0000 1.212
+++ gcc/cpplex.c 9 Sep 2002 13:52:17 -0000
@@ -82,10 +82,12 @@ static bool continue_after_nul PARAMS ((
static int name_p PARAMS ((cpp_reader *, const cpp_string *));
static int maybe_read_ucs PARAMS ((cpp_reader *, const unsigned char **,
const unsigned char *, cppchar_t *));
-static tokenrun *next_tokenrun PARAMS ((tokenrun *));
static unsigned int hex_digit_value PARAMS ((unsigned int));
static _cpp_buff *new_buff PARAMS ((size_t));
+static cpp_token *realloc_run PARAMS ((tokenrun *));
+static void lex_nonempty_line PARAMS ((cpp_reader *));
+static void lex_token PARAMS ((cpp_reader *, cpp_token *, int));
/* Utility routine:
@@ -470,15 +472,14 @@ parse_identifier (pfile)
if (__builtin_expect ((result->flags & NODE_DIAGNOSTIC)
&& !pfile->state.skipping, 0))
{
- /* It is allowed to poison the same identifier twice. */
- if ((result->flags & NODE_POISONED) && !pfile->state.poisoned_ok)
+ if (result->flags & NODE_POISONED)
cpp_error (pfile, DL_ERROR, "attempt to use poisoned \"%s\"",
NODE_NAME (result));
/* Constraint 6.10.3.5: __VA_ARGS__ should only appear in the
replacement list of a variadic macro. */
if (result == pfile->spec_nodes.n__VA_ARGS__
- && !pfile->state.va_args_ok)
+ && !_cpp_variadic_definition_p (pfile))
cpp_error (pfile, DL_PEDWARN,
"__VA_ARGS__ can only appear in the expansion of a C99 variadic macro");
}
@@ -727,6 +728,7 @@ parse_string (pfile, token, terminator)
token->val.str.text = BUFF_FRONT (pfile->u_buff);
token->val.str.len = dest - BUFF_FRONT (pfile->u_buff);
BUFF_FRONT (pfile->u_buff) = dest + 1;
+ pfile->state.angled_headers = 0;
}
/* The stored comment includes the comment start and any terminator. */
@@ -780,23 +782,22 @@ _cpp_init_tokenrun (run, count)
unsigned int count;
{
run->base = xnewvec (cpp_token, count);
+ run->end = run->base;
run->limit = run->base + count;
- run->next = NULL;
}
-/* Returns the next tokenrun, or creates one if there is none. */
-static tokenrun *
-next_tokenrun (run)
+/* Expand a token run. */
+static cpp_token *
+realloc_run (run)
tokenrun *run;
{
- if (run->next == NULL)
- {
- run->next = xnew (tokenrun);
- run->next->prev = run;
- _cpp_init_tokenrun (run->next, 250);
- }
+ size_t count = run->limit - run->base;
+ size_t n = count * 2;
- return run->next;
+ run->base = (cpp_token *) xrealloc (run->base, n * sizeof (cpp_token));
+ run->limit = run->base + n;
+ run->end = run->base + count;
+ return run->base + count;
}
/* Allocate a single token that is invalidated at the same time as the
@@ -810,72 +811,170 @@ _cpp_temp_token (pfile)
cpp_token *old, *result;
old = pfile->cur_token - 1;
- if (pfile->cur_token == pfile->cur_run->limit)
- {
- pfile->cur_run = next_tokenrun (pfile->cur_run);
- pfile->cur_token = pfile->cur_run->base;
- }
- result = pfile->cur_token++;
+ /* FIXME. */
+ result = xnew (cpp_token);
result->line = old->line;
result->col = old->col;
return result;
}
-/* Lex a token into RESULT (external interface). Takes care of issues
- like directive handling, token lookahead, multiple include
- optimization and skipping. */
+/* Lex a single token into TOKEN. Returns TRUE if there are more
+ characters in the buffer.
+
+ This is useful for lexing builtins and pasted tokens. */
+bool
+_cpp_lex_direct (pfile, token)
+ cpp_reader *pfile;
+ cpp_token *token;
+{
+ cpp_token *saved;
+
+ saved = pfile->cur_token;
+ lex_token (pfile, token, false);
+ pfile->cur_token = saved;
+
+ return pfile->buffer->cur != pfile->buffer->rlimit;
+}
+
+/* Return the next token in the lexed line of tokens. If there are no
+ tokens left, lex the next line. */
const cpp_token *
_cpp_lex_token (pfile)
cpp_reader *pfile;
{
- cpp_token *result;
+ if (pfile->state.in_directive)
+ {
+ /* At the end of the token line, don't re-lex a line if we're in
+ a directive. Instead, keep returning the CPP_EOF. */
+ if (pfile->cur_token > pfile->base_run.end)
+ pfile->cur_token = pfile->base_run.end;
+ }
+ else
+ {
+ if (pfile->cur_token >= pfile->base_run.end)
+ lex_nonempty_line (pfile);
- for (;;)
+ /* Outside a directive, invalidate controlling macros. At file
+ EOF lex_token takes care of popping the buffer, so we never
+ get here and MI optimisation works. */
+ pfile->mi_valid = false;
+ }
+
+ return pfile->cur_token++;
+}
+
+static void
+lex_nonempty_line (pfile)
+ cpp_reader *pfile;
+{
+ size_t start;
+ tokenrun *run = &pfile->base_run;
+
+ if (pfile->state.parsing_args || pfile->saved_end)
+ start = pfile->cur_token - pfile->base_run.base;
+ else
+ start = 0;
+
+ if (pfile->saved_end)
{
- if (pfile->cur_token == pfile->cur_run->limit)
- {
- pfile->cur_run = next_tokenrun (pfile->cur_run);
- pfile->cur_token = pfile->cur_run->base;
- }
+ run->end = pfile->saved_end;
+ pfile->saved_end = NULL;
+ pfile->cur_token = run->base + start;
+ pfile->state.in_directive = pfile->directive != 0;
+ if (pfile->directive)
+ goto handle_directive;
+ }
+ else
+ /* Loop whilst skipping or handling directives. */
+ for (;;)
+ {
+ bool drop_line = false;
+ cpp_token *token = run->base + start;
- if (pfile->lookaheads)
- {
- pfile->lookaheads--;
- result = pfile->cur_token++;
- }
- else
- result = _cpp_lex_direct (pfile);
+ if (token == run->limit)
+ token = realloc_run (run);
+ lex_token (pfile, token, true);
- if (result->flags & BOL)
- {
- /* Is this a directive. If _cpp_handle_directive returns
- false, it is an assembler #. */
- if (result->type == CPP_HASH
- /* 6.10.3 p 11: Directives in a list of macro arguments
- gives undefined behavior. This implementation
- handles the directive as normal. */
- && pfile->state.parsing_args != 1
- && _cpp_handle_directive (pfile, result->flags & PREV_WHITE))
- continue;
- if (pfile->cb.line_change && !pfile->state.skipping)
- (*pfile->cb.line_change)(pfile, result, pfile->state.parsing_args);
- }
+ if (token->type == CPP_EOF)
+ {
+ run->end = token;
+ pfile->cur_token = run->base + start;
+ return;
+ }
- /* We don't skip tokens in directives. */
- if (pfile->state.in_directive)
- break;
+ if (token->type == CPP_HASH)
+ {
+ pfile->directive_line = token->line;
+ token++;
+ if (token == run->limit)
+ token = realloc_run (run);
+ pfile->dir_first = token - pfile->base_run.base + 1;
+
+ pfile->state.in_directive = 1;
+ pfile->state.save_comments = 0;
+ lex_token (pfile, token, false);
+ drop_line = _cpp_classify_directive (pfile, token,
+ token[-1].flags & PREV_WHITE);
+ if (token->type == CPP_EOF)
+ continue;
+ }
- /* Outside a directive, invalidate controlling macros. At file
- EOF, _cpp_lex_direct takes care of popping the buffer, so we never
- get here and MI optimisation works. */
- pfile->mi_valid = false;
+ _cpp_lex_line (pfile, &pfile->base_run,
+ token - pfile->base_run.base + 1);
+ if (drop_line)
+ continue;
+
+ pfile->state.angled_headers = 0;
+ pfile->cur_token = run->base + start;
+ if (pfile->state.parsing_args == 2)
+ pfile->cur_token->flags |= PREV_WHITE;
+ else if (pfile->state.parsing_args == 1
+ && pfile->cur_token->type != CPP_OPEN_PAREN)
+ {
+ /* Yuk, but I can't immediately see a cleaner way. */
+ pfile->state.in_directive = 0;
+ pfile->saved_end = run->end;
+ run->end = pfile->cur_token;
+ return;
+ }
+
+ handle_directive:
+ if (pfile->directive)
+ _cpp_handle_directive (pfile);
+ else if (!pfile->state.skipping)
+ break;
+ }
+
+ if (pfile->cb.line_change)
+ (*pfile->cb.line_change) (pfile, pfile->cur_token,
+ pfile->state.parsing_args);
+}
- if (!pfile->state.skipping || result->type == CPP_EOF)
+/* Simply lex a logical line of tokens, starting at offset START in
+ token line RUN. */
+void
+_cpp_lex_line (pfile, run, start)
+ cpp_reader *pfile;
+ tokenrun *run;
+ size_t start;
+{
+ cpp_token *token;
+
+ if (pfile->saved_end)
+ cpp_error (pfile, DL_ICE, "saved token line in _cpp_lex_line");
+
+ for (token = run->base + start;; token++)
+ {
+ if (token == run->limit)
+ token = realloc_run (run);
+ lex_token (pfile, token, false);
+ if (token->type == CPP_EOF)
break;
}
- return result;
+ run->end = token;
+ pfile->cur_token = run->base + start;
}
/* A NUL terminates the current buffer. For ISO preprocessing this is
@@ -889,7 +988,6 @@ continue_after_nul (pfile)
cpp_buffer *buffer = pfile->buffer;
bool more = false;
- buffer->saved_flags = BOL;
if (CPP_OPTION (pfile, traditional))
{
if (pfile->state.in_directive)
@@ -905,14 +1003,12 @@ continue_after_nul (pfile)
{
/* Stop parsing arguments with a CPP_EOF. When we finally come
back here, do the work of popping the buffer. */
- if (!pfile->state.parsing_args)
+ if (!pfile->state.parsing_args && !buffer->from_stage3)
{
if (buffer->cur != buffer->line_base)
{
- /* Non-empty files should end in a newline. Don't warn
- for command line and _Pragma buffers. */
- if (!buffer->from_stage3)
- cpp_error (pfile, DL_PEDWARN, "no newline at end of file");
+ /* Non-empty files should end in a newline. */
+ cpp_error (pfile, DL_PEDWARN, "no newline at end of file");
handle_newline (pfile);
}
@@ -940,30 +1036,22 @@ continue_after_nul (pfile)
} \
} while (0)
-/* Lex a token into pfile->cur_token, which is also incremented, to
- get diagnostics pointing to the correct location.
-
- Does not handle issues such as token lookahead, multiple-include
- optimisation, directives, skipping etc. This function is only
- suitable for use by _cpp_lex_token, and in special cases like
- lex_expansion_token which doesn't care for any of these issues.
-
- When meeting a newline, returns CPP_EOF if parsing a directive,
- otherwise returns to the start of the token buffer if permissible.
- Returns the location of the lexed token. */
-cpp_token *
-_cpp_lex_direct (pfile)
+/* Lex a token directly into RESULT. If a newline is encountered,
+ returns CPP_EOF unless SKIP_NEWLINES. */
+static void
+lex_token (pfile, result, skip_newlines)
cpp_reader *pfile;
+ cpp_token *result;
+ int skip_newlines;
{
cppchar_t c;
cpp_buffer *buffer;
const unsigned char *comment_start;
- cpp_token *result = pfile->cur_token++;
+ pfile->cur_token = result + 1;
fresh_line:
buffer = pfile->buffer;
- result->flags = buffer->saved_flags;
- buffer->saved_flags = 0;
+ result->flags = 0;
update_tokens_line:
result->line = pfile->line;
@@ -988,19 +1076,8 @@ _cpp_lex_direct (pfile)
case '\n': case '\r':
handle_newline (pfile);
- buffer->saved_flags = BOL;
- if (! pfile->state.in_directive)
- {
- if (pfile->state.parsing_args == 2)
- buffer->saved_flags |= PREV_WHITE;
- if (!pfile->keep_tokens)
- {
- pfile->cur_run = &pfile->base_run;
- result = pfile->base_run.base;
- pfile->cur_token = result + 1;
- }
- goto fresh_line;
- }
+ if (skip_newlines)
+ goto fresh_line;
result->type = CPP_EOF;
break;
@@ -1343,8 +1420,6 @@ _cpp_lex_direct (pfile)
result->val.c = c;
break;
}
-
- return result;
}
/* An upper bound on the number of bytes needed to spell TOKEN,
============================================================
Index: gcc/cpplib.c
--- gcc/cpplib.c 5 Sep 2002 17:46:50 -0000 1.321.4.1
+++ gcc/cpplib.c 9 Sep 2002 13:52:18 -0000
@@ -95,9 +95,7 @@ struct directive
static void skip_rest_of_line PARAMS ((cpp_reader *));
static void check_eol PARAMS ((cpp_reader *));
-static void start_directive PARAMS ((cpp_reader *));
static void prepare_directive_trad PARAMS ((cpp_reader *));
-static void end_directive PARAMS ((cpp_reader *, int));
static void directive_diagnostics
PARAMS ((cpp_reader *, const directive *, int));
static void run_directive PARAMS ((cpp_reader *, int,
@@ -211,9 +209,7 @@ skip_rest_of_line (pfile)
_cpp_pop_context (pfile);
/* Sweep up all tokens remaining on the line. */
- if (! SEEN_EOL ())
- while (_cpp_lex_token (pfile)->type != CPP_EOF)
- ;
+ pfile->cur_token = pfile->base_run.end + 1;
}
/* Ensure there are no stray tokens at the end of a directive. */
@@ -226,52 +222,6 @@ check_eol (pfile)
pfile->directive->name);
}
-/* Called when entering a directive, _Pragma or command-line directive. */
-static void
-start_directive (pfile)
- cpp_reader *pfile;
-{
- /* Setup in-directive state. */
- pfile->state.in_directive = 1;
- pfile->state.save_comments = 0;
-
- /* Some handlers need the position of the # for diagnostics. */
- pfile->directive_line = pfile->line;
-}
-
-/* Called when leaving a directive, _Pragma or command-line directive. */
-static void
-end_directive (pfile, skip_line)
- cpp_reader *pfile;
- int skip_line;
-{
- if (CPP_OPTION (pfile, traditional))
- {
- /* Revert change of prepare_directive_trad. */
- pfile->state.prevent_expansion--;
-
- if (pfile->directive != &dtable[T_DEFINE])
- _cpp_remove_overlay (pfile);
- }
- /* We don't skip for an assembler #. */
- else if (skip_line)
- {
- skip_rest_of_line (pfile);
- if (!pfile->keep_tokens)
- {
- pfile->cur_run = &pfile->base_run;
- pfile->cur_token = pfile->base_run.base;
- }
- }
-
- /* Restore state. */
- pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
- pfile->state.in_directive = 0;
- pfile->state.in_expression = 0;
- pfile->state.angled_headers = 0;
- pfile->directive = 0;
-}
-
/* Prepare to handle the directive in pfile->directive. */
static void
prepare_directive_trad (pfile)
@@ -294,8 +244,11 @@ prepare_directive_trad (pfile)
pfile->state.skipping = was_skipping;
_cpp_overlay_buffer (pfile, pfile->out.base,
pfile->out.cur - pfile->out.base);
+ _cpp_lex_line (pfile, &pfile->base_run, 1);
}
+ pfile->dir_first = 1;
+
/* Stop ISO C from expanding anything. */
pfile->state.prevent_expansion++;
}
@@ -336,116 +289,154 @@ directive_diagnostics (pfile, dir, inden
}
}
-/* Check if we have a known directive. INDENTED is non-zero if the
- '#' of the directive was indented. This function is in this file
- to save unnecessarily exporting dtable etc. to cpplex.c. Returns
- non-zero if the line of tokens has been handled, zero if we should
- continue processing the line. */
-int
-_cpp_handle_directive (pfile, indented)
+/* Check if we have a known directive in TOKEN, storing its handler in
+ pfile->directive if so, otherwise NULL. INDENTED is non-zero if
+ the '#' of the directive was indented.
+
+ Returns non-zero to indicate an invalid directive. */
+bool
+_cpp_classify_directive (pfile, token, indented)
cpp_reader *pfile;
+ const cpp_token *token;
int indented;
{
+ bool invalid = false;
const directive *dir = 0;
- const cpp_token *dname;
- bool was_parsing_args = pfile->state.parsing_args;
- int skip = 1;
- if (was_parsing_args)
+ /* Assembler doesn't want diagnostics, and only accepts CPP_NAME
+ directives as actual directives. Everything else is treated as
+ normal tokens: we don't know where the comments are, and # may
+ introduce assembler pseudo-ops. */
+ if (CPP_OPTION (pfile, lang) == CLK_ASM)
{
- if (CPP_OPTION (pfile, pedantic))
- cpp_error (pfile, DL_PEDWARN,
- "embedding a directive within macro arguments is not portable");
- pfile->state.parsing_args = 0;
- pfile->state.prevent_expansion = 0;
- }
- start_directive (pfile);
- dname = _cpp_lex_token (pfile);
-
- if (dname->type == CPP_NAME)
- {
- if (dname->val.node->directive_index)
- dir = &dtable[dname->val.node->directive_index - 1];
- }
- /* We do not recognise the # followed by a number extension in
- assembler code. */
- else if (dname->type == CPP_NUMBER && CPP_OPTION (pfile, lang) != CLK_ASM)
- {
- dir = &linemarker_dir;
- if (CPP_PEDANTIC (pfile) && ! CPP_OPTION (pfile, preprocessed)
- && ! pfile->state.skipping)
- cpp_error (pfile, DL_PEDWARN,
- "style of line directive is a GCC extension");
+ if (token->type == CPP_NAME && token->val.node->directive_index)
+ dir = &dtable[token->val.node->directive_index - 1];
}
-
- if (dir)
+ else
{
- /* If we have a directive that is not an opening conditional,
- invalidate any control macro. */
- if (! (dir->flags & IF_COND))
- pfile->mi_valid = false;
-
- /* Kluge alert. In order to be sure that code like this
-
- #define HASH #
- HASH define foo bar
-
- does not cause '#define foo bar' to get executed when
- compiled with -save-temps, we recognize directives in
- -fpreprocessed mode only if the # is in column 1. cppmacro.c
- puts a space in front of any '#' at the start of a macro. */
- if (CPP_OPTION (pfile, preprocessed)
- && (indented || !(dir->flags & IN_I)))
+ if (pfile->state.parsing_args == 2 && CPP_OPTION (pfile, std))
+ cpp_error (pfile, DL_WARNING,
+ "embedding a directive within macro arguments is not portable");
+
+ switch (token->type)
{
- skip = 0;
- dir = 0;
+ case CPP_EOF:
+ pfile->state.in_directive = 0;
+ break;
+
+ case CPP_NUMBER:
+ dir = &linemarker_dir;
+ if (CPP_PEDANTIC (pfile)
+ && ! CPP_OPTION (pfile, preprocessed)
+ && ! pfile->state.skipping)
+ cpp_error (pfile, DL_PEDWARN,
+ "style of line directive is a GCC extension");
+ break;
+
+ case CPP_NAME:
+ if (token->val.node->directive_index)
+ {
+ dir = &dtable[token->val.node->directive_index - 1];
+
+ /* Kluge alert. In order to be sure that code like this
+
+ #define HASH #
+ HASH define foo bar
+
+ does not cause '#define foo bar' to get executed when
+ compiled with -save-temps, we recognize directives in
+ -fpreprocessed mode only if the # is in column 1.
+ cppmacro.c puts a space in front of any '#' at the start
+ of a macro.
+
+ Further, only IN_I directives are recognised in
+ preprocessed source. */
+ if (CPP_OPTION (pfile, preprocessed))
+ {
+ if (indented || !(dir->flags & IN_I))
+ dir = 0;
+ }
+ else
+ directive_diagnostics (pfile, dir, indented);
+ }
+ else
+ invalid = true;
+ break;
+
+ default:
+ invalid = true;
+ break;
}
+ }
+
+ if (dir)
+ {
+ /* In failed conditional groups, all non-conditional directives
+ are ignored. */
+ if (pfile->state.skipping && !(dir->flags & COND))
+ dir = 0;
else
{
- /* In failed conditional groups, all non-conditional
- directives are ignored. Before doing that, whether
- skipping or not, we should lex angle-bracketed headers
- correctly, and maybe output some diagnostics. */
- pfile->state.angled_headers = dir->flags & INCL;
- if (! CPP_OPTION (pfile, preprocessed))
- directive_diagnostics (pfile, dir, indented);
- if (pfile->state.skipping && !(dir->flags & COND))
- dir = 0;
+ if (dir->flags & INCL)
+ pfile->state.angled_headers = 1;
+ /* If we have a directive that is not an opening
+ conditional, invalidate any control macro. */
+ if (! (dir->flags & IF_COND))
+ pfile->mi_valid = false;
}
}
- else if (dname->type == CPP_EOF)
- ; /* CPP_EOF is the "null directive". */
+
+ pfile->directive = dir;
+ if (dir)
+ pfile->state.save_comments
+ = (dir == &dtable[T_DEFINE]
+ && !CPP_OPTION (pfile, discard_comments_in_macro_exp));
else
{
- /* An unknown directive. Don't complain about it in assembly
- source: we don't know where the comments are, and # may
- introduce assembler pseudo-ops. Don't complain about invalid
- directives in skipped conditional groups (6.10 p4). */
- if (CPP_OPTION (pfile, lang) == CLK_ASM)
- skip = 0;
- else if (!pfile->state.skipping)
+ pfile->state.save_comments = !CPP_OPTION (pfile, discard_comments);
+ pfile->state.in_directive = 0;
+ if (invalid && !pfile->state.skipping)
cpp_error (pfile, DL_ERROR, "invalid preprocessing directive #%s",
- cpp_token_as_text (pfile, dname));
+ cpp_token_as_text (pfile, token));
}
- pfile->directive = dir;
+ return invalid;
+}
+
+void
+_cpp_handle_directive (pfile)
+ cpp_reader *pfile;
+{
+ uchar was_parsing_args = pfile->state.parsing_args;
+
+ pfile->state.in_directive = 1;
+ pfile->state.parsing_args = 0;
+ pfile->state.prevent_expansion = 0;
if (CPP_OPTION (pfile, traditional))
prepare_directive_trad (pfile);
+ pfile->cur_token = pfile->base_run.base + pfile->dir_first;
+ (*pfile->directive->handler) (pfile);
+ pfile->state.in_directive = 0;
+ pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
+ pfile->state.in_expression = 0;
+ pfile->state.angled_headers = 0;
+ skip_rest_of_line (pfile);
- if (dir)
- (*pfile->directive->handler) (pfile);
- else if (skip == 0)
- _cpp_backup_tokens (pfile, 1);
+ if (CPP_OPTION (pfile, traditional))
+ {
+ /* Revert change of prepare_directive_trad. */
+ pfile->state.prevent_expansion--;
+
+ if (pfile->directive != &dtable[T_DEFINE])
+ _cpp_remove_overlay (pfile);
+ }
+ pfile->directive = 0;
- end_directive (pfile, skip);
if (was_parsing_args)
{
- /* Restore state when within macro args. */
- pfile->state.parsing_args = 2;
+ pfile->state.parsing_args = was_parsing_args;
pfile->state.prevent_expansion = 1;
- pfile->buffer->saved_flags |= PREV_WHITE;
}
- return skip;
}
/* Directive handler wrapper used by the command line option
@@ -462,16 +453,18 @@ run_directive (pfile, dir_no, buf, count
/* Disgusting hack. */
if (dir_no == T_PRAGMA)
pfile->buffer->inc = pfile->buffer->prev->inc;
- start_directive (pfile);
- /* We don't want a leading # to be interpreted as a directive. */
- pfile->buffer->saved_flags = 0;
+ pfile->directive_line = pfile->line;
+ pfile->state.in_directive = 1;
+ pfile->state.save_comments = 0;
pfile->directive = &dtable[dir_no];
- if (CPP_OPTION (pfile, traditional))
- prepare_directive_trad (pfile);
- (void) (*pfile->directive->handler) (pfile);
- end_directive (pfile, 1);
+ pfile->dir_first = 0;
+ if (!CPP_OPTION (pfile, traditional))
+ _cpp_lex_line (pfile, &pfile->base_run, 0);
+ _cpp_handle_directive (pfile);
if (dir_no == T_PRAGMA)
pfile->buffer->inc = NULL;
+ else /* Make the command line directive take up a line. */
+ pfile->line++;
_cpp_pop_buffer (pfile);
}
@@ -481,7 +474,16 @@ static cpp_hashnode *
lex_macro_node (pfile)
cpp_reader *pfile;
{
- const cpp_token *token = _cpp_lex_token (pfile);
+ cpp_token temp;
+ const cpp_token *token;
+
+ do
+ if (CPP_OPTION (pfile, traditional)
+ && pfile->directive == &dtable[T_DEFINE])
+ _cpp_lex_direct (pfile, &temp), token = &temp;
+ else
+ token = _cpp_lex_token (pfile);
+ while (token->type == CPP_COMMENT);
/* The token immediately after #define must be an identifier. That
identifier may not be "defined", per C99 6.10.8p4.
@@ -520,17 +522,9 @@ do_define (pfile)
{
cpp_hashnode *node = lex_macro_node (pfile);
- if (node)
- {
- /* If we have been requested to expand comments into macros,
- then re-enable saving of comments. */
- pfile->state.save_comments =
- ! CPP_OPTION (pfile, discard_comments_in_macro_exp);
-
- if (_cpp_create_definition (pfile, node))
- if (pfile->cb.define)
- (*pfile->cb.define) (pfile, pfile->directive_line, node);
- }
+ if (node &&_cpp_create_definition (pfile, node))
+ if (pfile->cb.define)
+ (*pfile->cb.define) (pfile, pfile->directive_line, node);
}
/* Handle #undef. Mark the identifier NT_VOID in the hash table. */
@@ -851,16 +845,11 @@ do_linemarker (pfile)
enum lc_reason reason = LC_RENAME;
int flag;
- /* Back up so we can get the number again. Putting this in
- _cpp_handle_directive risks two calls to _cpp_backup_tokens in
- some circumstances, which can segfault. */
- _cpp_backup_tokens (pfile, 1);
+ /* Back up so we can get the number again. */
+ pfile->cur_token--;
- /* #line commands expand macros. */
token = cpp_get_token (pfile);
- if (token->type != CPP_NUMBER
- || strtoul_for_line (token->val.str.text, token->val.str.len,
- &new_lineno))
+ if (strtoul_for_line (token->val.str.text, token->val.str.len, &new_lineno))
{
cpp_error (pfile, DL_ERROR, "\"%s\" after # is not a positive integer",
cpp_token_as_text (pfile, token));
@@ -1156,7 +1145,6 @@ do_pragma_poison (pfile)
const cpp_token *tok;
cpp_hashnode *hp;
- pfile->state.poisoned_ok = 1;
for (;;)
{
tok = _cpp_lex_token (pfile);
@@ -1178,7 +1166,6 @@ do_pragma_poison (pfile)
_cpp_free_definition (hp);
hp->flags |= NODE_POISONED | NODE_DIAGNOSTIC;
}
- pfile->state.poisoned_ok = 0;
}
/* Mark the current header as a system header. This will suppress
@@ -1934,7 +1921,6 @@ cpp_push_buffer (pfile, buffer, len, fro
new->from_stage3 = from_stage3 || CPP_OPTION (pfile, traditional);
new->prev = pfile->buffer;
new->return_at_eof = return_at_eof;
- new->saved_flags = BOL;
pfile->buffer = new;
@@ -1997,4 +1983,48 @@ _cpp_init_directives (pfile)
node = cpp_lookup (pfile, dtable[i].name, dtable[i].length);
node->directive_index = i + 1;
}
+}
+
+/* Returns true if we're in the definition part of a variadic macro. */
+bool
+_cpp_variadic_definition_p (pfile)
+ cpp_reader *pfile;
+{
+ if (pfile->directive == &dtable[T_DEFINE])
+ {
+ enum {MACNAME, OPEN_PAREN, ELLIPSIS, CLOSE_PAREN} state = MACNAME;
+ cpp_token *token;
+
+ for (token = pfile->base_run.base + pfile->dir_first;
+ token != pfile->cur_token;
+ token++)
+ {
+ if (token->type == CPP_COMMENT)
+ continue;
+ if (token->type == CPP_CLOSE_PAREN)
+ return state == CLOSE_PAREN;
+
+ if (state == MACNAME)
+ {
+ if (token->type != CPP_NAME)
+ break;
+ state = OPEN_PAREN;
+ }
+ else if (state == OPEN_PAREN)
+ {
+ if (token->type != CPP_OPEN_PAREN || token->flags & PREV_WHITE)
+ break;
+ state = ELLIPSIS;
+ }
+ else if (state == ELLIPSIS)
+ {
+ if (token->type == CPP_ELLIPSIS)
+ state = CLOSE_PAREN;
+ }
+ else
+ break;
+ }
+ }
+
+ return false;
}
============================================================
Index: gcc/cpplib.h
--- gcc/cpplib.h 14 Aug 2002 22:34:47 -0000 1.234
+++ gcc/cpplib.h 9 Sep 2002 13:52:18 -0000
@@ -169,7 +169,6 @@ struct cpp_string
#define PASTE_LEFT (1 << 3) /* If on LHS of a ## operator. */
#define NAMED_OP (1 << 4) /* C++ named operators. */
#define NO_EXPAND (1 << 5) /* Do not macro-expand this token. */
-#define BOL (1 << 6) /* Token at beginning of line. */
/* A preprocessing token. This has been carefully packed and should
occupy 16 bytes on 32-bit hosts and 24 bytes on 64-bit hosts. */
============================================================
Index: gcc/cppmacro.c
--- gcc/cppmacro.c 7 Aug 2002 21:47:47 -0000 1.122
+++ gcc/cppmacro.c 9 Sep 2002 13:52:19 -0000
@@ -265,6 +265,7 @@ builtin_macro (pfile, node)
cpp_hashnode *node;
{
const uchar *buf;
+ cpp_token *token;
if (node->value.builtin == BT_PRAGMA)
{
@@ -284,15 +285,12 @@ builtin_macro (pfile, node)
/* Tweak the column number the lexer will report. */
pfile->buffer->col_adjust = pfile->cur_token[-1].col - 1;
- /* We don't want a leading # to be interpreted as a directive. */
- pfile->buffer->saved_flags = 0;
-
/* Set pfile->cur_token as required by _cpp_lex_direct. */
- pfile->cur_token = _cpp_temp_token (pfile);
- push_token_context (pfile, NULL, _cpp_lex_direct (pfile), 1);
- if (pfile->buffer->cur != pfile->buffer->rlimit)
+ token = _cpp_temp_token (pfile);
+ if (_cpp_lex_direct (pfile, token))
cpp_error (pfile, DL_ICE, "invalid built-in macro \"%s\"",
NODE_NAME (node));
+ push_token_context (pfile, NULL, token, 1);
_cpp_pop_buffer (pfile);
return 1;
@@ -424,6 +422,7 @@ paste_tokens (pfile, plhs, rhs)
{
unsigned char *buf, *end;
const cpp_token *lhs;
+ cpp_token *temp;
unsigned int len;
bool valid;
@@ -447,13 +446,9 @@ paste_tokens (pfile, plhs, rhs)
/* Tweak the column number the lexer will report. */
pfile->buffer->col_adjust = pfile->cur_token[-1].col - 1;
- /* We don't want a leading # to be interpreted as a directive. */
- pfile->buffer->saved_flags = 0;
-
- /* Set pfile->cur_token as required by _cpp_lex_direct. */
- pfile->cur_token = _cpp_temp_token (pfile);
- *plhs = _cpp_lex_direct (pfile);
- valid = pfile->buffer->cur == pfile->buffer->rlimit;
+ temp = _cpp_temp_token (pfile);
+ valid = !_cpp_lex_direct (pfile, temp);
+ *plhs = temp;
_cpp_pop_buffer (pfile);
return valid;
@@ -627,8 +622,7 @@ collect_args (pfile, node)
&& ! (macro->variadic && argc == macro->paramc))
break;
}
- else if (token->type == CPP_EOF
- || (token->type == CPP_HASH && token->flags & BOL))
+ else if (token->type == CPP_EOF)
break;
arg->first[ntokens++] = token;
@@ -720,7 +714,7 @@ funlike_invocation_p (pfile, node)
/* CPP_EOF can be the end of macro arguments, or the end of the
file. We mustn't back up over the latter. Ugh. */
- if (token->type != CPP_EOF || token == &pfile->eof)
+ if (token->type != CPP_EOF || pfile->context->prev)
{
/* Back up. We may have skipped padding, in which case backing
up more than one token when expanding macros is in general
@@ -745,8 +739,6 @@ enter_macro_context (pfile, node)
/* The presence of a macro invalidates a file's controlling macro. */
pfile->mi_valid = false;
- pfile->state.angled_headers = false;
-
/* Handle standard macros. */
if (! (node->flags & NODE_BUILTIN))
{
@@ -757,11 +749,9 @@ enter_macro_context (pfile, node)
_cpp_buff *buff;
pfile->state.prevent_expansion++;
- pfile->keep_tokens++;
pfile->state.parsing_args = 1;
buff = funlike_invocation_p (pfile, node);
pfile->state.parsing_args = 0;
- pfile->keep_tokens--;
pfile->state.prevent_expansion--;
if (buff == NULL)
@@ -1206,20 +1196,7 @@ _cpp_backup_tokens (pfile, count)
unsigned int count;
{
if (pfile->context->prev == NULL)
- {
- pfile->lookaheads += count;
- while (count--)
- {
- pfile->cur_token--;
- if (pfile->cur_token == pfile->cur_run->base
- /* Possible with -fpreprocessed and no leading #line. */
- && pfile->cur_run->prev != NULL)
- {
- pfile->cur_run = pfile->cur_run->prev;
- pfile->cur_token = pfile->cur_run->limit;
- }
- }
- }
+ pfile->cur_token -= count;
else
{
if (count != 1)
@@ -1371,7 +1348,6 @@ parse_params (pfile, macro)
{
_cpp_save_parameter (pfile, macro,
pfile->spec_nodes.n__VA_ARGS__);
- pfile->state.va_args_ok = 1;
if (! CPP_OPTION (pfile, c99) && CPP_OPTION (pfile, pedantic))
cpp_error (pfile, DL_PEDWARN,
"anonymous variadic macros were introduced in C99");
@@ -1414,8 +1390,8 @@ lex_expansion_token (pfile, macro)
{
cpp_token *token;
- pfile->cur_token = alloc_expansion_token (pfile, macro);
- token = _cpp_lex_direct (pfile);
+ token = alloc_expansion_token (pfile, macro);
+ *token = *_cpp_lex_token (pfile);
/* Is this a parameter? */
if (token->type == CPP_NAME && token->val.node->arg_index)
@@ -1551,23 +1527,7 @@ _cpp_create_definition (pfile, node)
if (CPP_OPTION (pfile, traditional))
ok = _cpp_create_trad_definition (pfile, macro);
else
- {
- cpp_token *saved_cur_token = pfile->cur_token;
-
- ok = create_iso_definition (pfile, macro);
-
- /* Restore lexer position because of games lex_expansion_token()
- plays lexing the macro. We set the type for SEEN_EOL() in
- cpplib.c.
-
- Longer term we should lex the whole line before coming here,
- and just copy the expansion. */
- saved_cur_token[-1].type = pfile->cur_token[-1].type;
- pfile->cur_token = saved_cur_token;
-
- /* Stop the lexer accepting __VA_ARGS__. */
- pfile->state.va_args_ok = 0;
- }
+ ok = create_iso_definition (pfile, macro);
/* Clear the fast argument lookup indices. */
for (i = macro->paramc; i-- > 0; )
============================================================
Index: gcc/cpptrad.c
--- gcc/cpptrad.c 23 Jul 2002 22:57:44 -0000 1.27
+++ gcc/cpptrad.c 9 Sep 2002 13:52:19 -0000
@@ -484,8 +484,10 @@ scan_out_logical_line (pfile, macro)
/* Premature end of file. Fake a new line. */
cur--;
if (!pfile->buffer->from_stage3)
- cpp_error (pfile, DL_PEDWARN, "no newline at end of file");
- pfile->line++;
+ {
+ cpp_error (pfile, DL_PEDWARN, "no newline at end of file");
+ pfile->line++;
+ }
goto done;
case '\r': case '\n':
@@ -684,44 +686,33 @@ scan_out_logical_line (pfile, macro)
case '#':
if (out - 1 == pfile->out.base && !pfile->state.in_directive)
{
+ cpp_token *token = pfile->base_run.base;
+
/* A directive. With the way _cpp_handle_directive
currently works, we only want to call it if either we
know the directive is OK, or we want it to fail and
be removed from the output. If we want it to be
passed through (the assembler case) then we must not
call _cpp_handle_directive. */
- pfile->out.cur = out;
- cur = skip_whitespace (pfile, cur, true /* skip_comments */);
- out = pfile->out.cur;
-
- if (is_vspace (*cur))
+ pfile->buffer->cur = cur;
+ pfile->directive_line = pfile->line;
+ pfile->state.save_comments = 0;
+ _cpp_lex_direct (pfile, token);
+ _cpp_classify_directive (pfile, token, false);
+ if (token->type == CPP_EOF)
{
/* Null directive. Ignore it and don't invalidate
the MI optimization. */
out = pfile->out.base;
+ cur = pfile->buffer->cur;
continue;
}
- else
+ if (pfile->directive)
{
- bool do_it = false;
-
- if (is_numstart (*cur))
- do_it = true;
- else if (is_idstart (*cur))
- /* Check whether we know this directive, but don't
- advance. */
- do_it = lex_identifier (pfile, cur)->directive_index != 0;
-
- if (do_it || CPP_OPTION (pfile, lang) != CLK_ASM)
- {
- /* This is a kludge. We want to have the ISO
- 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;
- }
+ _cpp_handle_directive (pfile);
+ /* #include changes pfile->buffer so we need to
+ update the limits of the current context. */
+ goto start_logical_line;
}
}
============================================================
Index: gcc/testsuite/gcc.dg/cpp/_Pragma1.c
--- testsuite/gcc.dg/cpp/_Pragma1.c 15 Nov 2000 19:23:41 -0000 1.2
+++ testsuite/gcc.dg/cpp/_Pragma1.c 9 Sep 2002 13:52:19 -0000
@@ -24,8 +24,10 @@ p4 /* No problem; not yet poisoned.
#define M2(x) _Pragma (#x)
/* Now test macro expansion with embedded _Pragmas. */
-M1 p4 /* { dg-error "poisoned" } */
-M2 (GCC poison p5) p5 /* { dg-error "poisoned" } */
+M1
+p4 /* { dg-error "poisoned" } */
+M2 (GCC poison p5)
+p5 /* { dg-error "poisoned" } */
/* Not interpreting _Pragma in directives means they don't nest. */
_Pragma ("_Pragma (\"GCC poison p6\") GCC poison p7")
============================================================
Index: gcc/testsuite/gcc.dg/cpp/_Pragma4.c
--- testsuite/gcc.dg/cpp/_Pragma4.c 5 Sep 2002 17:47:57 -0000 1.1.2.1
+++ testsuite/gcc.dg/cpp/_Pragma4.c 9 Sep 2002 13:52:19 -0000
@@ -7,6 +7,6 @@ a b c
/*
{ dg-final { if ![file exists _Pragma4.i] { return } } }
- { dg-final { if { [grep _Pragma4.i "#pragma bat "] != "" } { return } } }
+ { dg-final { if { [grep _Pragma4.i "#pragma bar "] != "" } { return } } }
{ dg-final { fail "_Pragma4.c: #pragma appearing on its own line" } }
*/
============================================================
Index: gcc/testsuite/gcc.dg/cpp/mac-dir-2.c
--- testsuite/gcc.dg/cpp/mac-dir-2.c 27 Feb 2002 07:24:53 -0000 1.1
+++ testsuite/gcc.dg/cpp/mac-dir-2.c 9 Sep 2002 13:52:19 -0000
@@ -1,12 +1,11 @@
/* Copyright (C) 2002 Free Software Foundation, Inc. */
/* { dg-do preprocess } */
+/* { dg-options "-std=c89" } */
/* Source: Neil Booth, 26 Feb 2002.
Test that we allow directives in macro arguments. */
-
-/* { dg-do preprocess } */
#define f(x) x
============================================================
Index: gcc/testsuite/gcc.dg/cpp/tr-paste.c
--- testsuite/gcc.dg/cpp/tr-paste.c 18 Nov 2001 17:16:24 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,17 +0,0 @@
-/* Test for proper comment elimination semantics from cpplib's -traditional.
- This should compile and link with compiled with `gcc -traditional-cpp'.
- Test case by Jason R. Thorpe <thorpej@zembu.com>. */
-
-/* { dg-do compile } */
-/* { dg-options "-traditional-cpp" } */
-
-#define A(name) X/**/name
-
-#define B(name) \
-void A(Y/**/name)() { A(name)(); }
-
-void Xhello() { printf("hello world\n"); }
-
-B(hello)
-
-int main() { XYhello(); return (0); }
============================================================
Index: gcc/testsuite/gcc.dg/cpp/trad/tr-paste.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/cpp/trad/tr-paste.c 9 Sep 2002 13:52:19 -0000
@@ -0,0 +1,16 @@
+/* Test for proper comment elimination semantics from cpplib's -traditional.
+ This should compile and link with compiled with `gcc -traditional-cpp'.
+ Test case by Jason R. Thorpe <thorpej@zembu.com>. */
+
+/* { dg-do compile } */
+
+#define A(name) X/**/name
+
+#define B(name) \
+void A(Y/**/name)() { A(name)(); }
+
+void Xhello() { printf("hello world\n"); }
+
+B(hello)
+
+int main() { XYhello(); return (0); }