aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNeil Booth <neilb@earthling.net>2000-11-13 18:40:37 +0000
committerNeil Booth <neil@gcc.gnu.org>2000-11-13 18:40:37 +0000
commit29b10746ab46f5901534d712d6108f219aceff97 (patch)
tree6bca53154943312d4ce1d3788de1f631c994d6c8 /gcc
parenteb68ad7c6025a667e77ea59e85ab37612e4593de (diff)
downloadgcc-29b10746ab46f5901534d712d6108f219aceff97.zip
gcc-29b10746ab46f5901534d712d6108f219aceff97.tar.gz
gcc-29b10746ab46f5901534d712d6108f219aceff97.tar.bz2
cpplex.c (_cpp_lex_token): CPP_COMMENT and true CPP_EOF cases return without MI check.
* cpplex.c (_cpp_lex_token): CPP_COMMENT and true CPP_EOF cases return without MI check. * cpplib.c (do_diagnostic): Take boolean of whether to print the directive name. (do_error, do_warning): Update. (do_pragma_dependency): Use it. * cpplib.h (VARARGS_FIRST): Delete. (struct cpp_token): Delete integer. * cppmacro.c (enter_macro_context): Move disabled check to _cpp_get_token. (_cpp_get_token): Simplify into a single loop. From-SVN: r37434
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/cpplex.c12
-rw-r--r--gcc/cpplib.c16
-rw-r--r--gcc/cpplib.h2
-rw-r--r--gcc/cppmacro.c80
5 files changed, 65 insertions, 59 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 87cc5ae..e980c45 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+2000-11-13 Neil Booth <neilb@earthling.net>
+
+ * cpplex.c (_cpp_lex_token): CPP_COMMENT and true CPP_EOF
+ cases return without MI check.
+ * cpplib.c (do_diagnostic): Take boolean of whether to
+ print the directive name.
+ (do_error, do_warning): Update.
+ (do_pragma_dependency): Use it.
+ * cpplib.h (VARARGS_FIRST): Delete.
+ (struct cpp_token): Delete integer.
+ * cppmacro.c (enter_macro_context): Move disabled check
+ to _cpp_get_token.
+ (_cpp_get_token): Simplify into a single loop.
+
2000-11-13 Richard Earnshaw <rearnsha@arm.com>
* configure.in: Use 'test -f' not '[ -e'.
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index 75d094d..8717104 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -876,7 +876,8 @@ _cpp_lex_token (pfile, result)
pfile->state.next_bol = 1;
pfile->skipping = 0; /* In case missing #endif. */
result->type = CPP_EOF;
- break;
+ /* Don't do MI optimisation. */
+ return;
case ' ': case '\t': case '\f': case '\v': case '\0':
skip_whitespace (pfile, c);
@@ -1032,7 +1033,8 @@ _cpp_lex_token (pfile, result)
/* Save the comment as a token in its own right. */
save_comment (pfile, result, comment_start);
- break;
+ /* Don't do MI optimisation. */
+ return;
case '<':
if (pfile->state.angled_headers)
@@ -1272,10 +1274,8 @@ _cpp_lex_token (pfile, result)
break;
}
- /* Non-comment tokens invalidate any controlling macros. */
- if (result->type != CPP_COMMENT
- && result->type != CPP_EOF
- && !pfile->state.in_directive)
+ /* If not in a directive, this token invalidates controlling macros. */
+ if (!pfile->state.in_directive)
pfile->mi_state = MI_FAILED;
}
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index 159c3db8..77cf6cd 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -91,7 +91,7 @@ static void push_conditional PARAMS ((cpp_reader *, int, int,
static int read_line_number PARAMS ((cpp_reader *, int *));
static int strtoul_for_line PARAMS ((const U_CHAR *, unsigned int,
unsigned long *));
-static void do_diagnostic PARAMS ((cpp_reader *, enum error_type));
+static void do_diagnostic PARAMS ((cpp_reader *, enum error_type, int));
static cpp_hashnode *lex_macro_node PARAMS ((cpp_reader *));
static void do_pragma_once PARAMS ((cpp_reader *));
static void do_pragma_poison PARAMS ((cpp_reader *));
@@ -792,13 +792,15 @@ do_line (pfile)
*/
static void
-do_diagnostic (pfile, code)
+do_diagnostic (pfile, code, print_dir)
cpp_reader *pfile;
enum error_type code;
+ int print_dir;
{
if (_cpp_begin_message (pfile, code, NULL, 0))
{
- fprintf (stderr, "#%s ", pfile->directive->name);
+ if (print_dir)
+ fprintf (stderr, "#%s ", pfile->directive->name);
pfile->state.prevent_expansion++;
cpp_output_line (pfile, stderr);
pfile->state.prevent_expansion--;
@@ -809,14 +811,14 @@ static void
do_error (pfile)
cpp_reader *pfile;
{
- do_diagnostic (pfile, ERROR);
+ do_diagnostic (pfile, ERROR, 1);
}
static void
do_warning (pfile)
cpp_reader *pfile;
{
- do_diagnostic (pfile, WARNING);
+ do_diagnostic (pfile, WARNING, 1);
}
/* Report program identification. */
@@ -1085,8 +1087,8 @@ do_pragma_dependency (pfile)
cpp_start_lookahead (pfile);
cpp_get_token (pfile, &msg);
cpp_stop_lookahead (pfile, msg.type == CPP_EOF);
- if (msg.type != CPP_EOF && _cpp_begin_message (pfile, WARNING, NULL, 0))
- cpp_output_line (pfile, stderr);
+ if (msg.type != CPP_EOF)
+ do_diagnostic (pfile, WARNING, 0);
}
}
diff --git a/gcc/cpplib.h b/gcc/cpplib.h
index 8b6560d..1cda3e9 100644
--- a/gcc/cpplib.h
+++ b/gcc/cpplib.h
@@ -170,7 +170,6 @@ struct cpp_string
#define PASTE_LEFT (1 << 3) /* If on LHS of a ## operator. */
#define NAMED_OP (1 << 4) /* C++ named operators, also "defined". */
#define NO_EXPAND (1 << 5) /* Do not macro-expand this token. */
-#define VARARGS_FIRST STRINGIFY_ARG /* First token of varargs expansion. */
/* A preprocessing token. This has been carefully packed and should
occupy 12 bytes on 32-bit hosts and 16 bytes on 64-bit hosts. */
@@ -181,7 +180,6 @@ struct cpp_token
union
{
- HOST_WIDEST_INT integer; /* An integer. */
struct cpp_hashnode *node; /* An identifier. */
struct cpp_string str; /* A string, or number. */
unsigned int arg_no; /* Argument no. for a CPP_MACRO_ARG. */
diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c
index 7ea70850..3d4af7e 100644
--- a/gcc/cppmacro.c
+++ b/gcc/cppmacro.c
@@ -60,7 +60,7 @@ struct macro_arg
static void lock_pools PARAMS ((cpp_reader *));
static void unlock_pools PARAMS ((cpp_reader *));
-static int enter_macro_context PARAMS ((cpp_reader *, cpp_token *));
+static int enter_macro_context PARAMS ((cpp_reader *, cpp_hashnode *));
static void builtin_macro PARAMS ((cpp_reader *, cpp_token *));
static cpp_context *push_arg_context PARAMS ((cpp_reader *, macro_arg *));
static enum cpp_ttype parse_arg PARAMS ((cpp_reader *, macro_arg *, int));
@@ -631,22 +631,14 @@ funlike_invocation_p (pfile, node, list)
TOKEN is replaced with the first token of the expansion, and we
return non-zero. */
static int
-enter_macro_context (pfile, token)
+enter_macro_context (pfile, node)
cpp_reader *pfile;
- cpp_token *token;
+ cpp_hashnode *node;
{
cpp_context *context;
- cpp_macro *macro;
- unsigned char flags;
+ cpp_macro *macro = node->value.macro;
struct toklist list;
- macro = token->val.node->value.macro;
- if (macro->disabled)
- {
- token->flags |= NO_EXPAND;
- return 0;
- }
-
/* Save the position of the outermost macro invocation. */
if (!pfile->context->prev)
{
@@ -654,7 +646,7 @@ enter_macro_context (pfile, token)
lock_pools (pfile);
}
- if (macro->fun_like && !funlike_invocation_p (pfile, token->val.node, &list))
+ if (macro->fun_like && !funlike_invocation_p (pfile, node, &list))
{
if (!pfile->context->prev)
unlock_pools (pfile);
@@ -667,22 +659,16 @@ enter_macro_context (pfile, token)
list.limit = macro->expansion + macro->count;
}
- /* Temporary kludge. */
- if (list.first == list.limit)
- return 2;
-
- /* Now push its context. */
- context = next_context (pfile);
- context->list = list;
- context->macro = macro;
-
- /* The first expansion token inherits the PREV_WHITE of TOKEN. */
- flags = token->flags & PREV_WHITE;
- *token = *context->list.first++;
- token->flags |= flags;
+ if (list.first != list.limit)
+ {
+ /* Push its context. */
+ context = next_context (pfile);
+ context->list = list;
+ context->macro = macro;
- /* Disable the macro within its expansion. */
- macro->disabled = 1;
+ /* Disable the macro within its expansion. */
+ macro->disabled = 1;
+ }
return 1;
}
@@ -895,8 +881,9 @@ _cpp_get_token (pfile, token)
cpp_reader *pfile;
cpp_token *token;
{
- next_token:
- do
+ unsigned char flags = 0;
+
+ for (;;)
{
cpp_context *context = pfile->context;
@@ -906,24 +893,28 @@ _cpp_get_token (pfile, token)
else if (!context->prev)
_cpp_lex_token (pfile, token);
else if (context->list.first != context->list.limit)
- *token = *context->list.first++;
+ {
+ *token = *context->list.first++;
+ token->flags |= flags;
+ flags = 0;
+ }
else
{
if (context->macro)
{
_cpp_pop_context (pfile);
- goto next_token;
+ continue;
}
/* End of argument pre-expansion. */
token->type = CPP_EOF;
token->flags = 0;
return;
}
- }
- while (pfile->skipping);
- for (;;)
- {
+ /* Loop until we're not skipping. */
+ if (pfile->skipping)
+ continue;
+
if (token->flags & PASTE_LEFT)
paste_all_tokens (pfile, token);
@@ -935,31 +926,32 @@ _cpp_get_token (pfile, token)
&& !pfile->state.prevent_expansion
&& !(token->flags & NO_EXPAND))
{
- int m;
+ cpp_hashnode *node = token->val.node;
/* Macros invalidate controlling macros. */
pfile->mi_state = MI_FAILED;
- if (token->val.node->flags & NODE_BUILTIN)
+ if (node->flags & NODE_BUILTIN)
{
builtin_macro (pfile, token);
break;
}
- m = enter_macro_context (pfile, token);
- if (m == 1)
+ /* Merge PREV_WHITE of tokens. */
+ flags = token->flags & PREV_WHITE;
+
+ if (node->value.macro->disabled)
+ token->flags |= NO_EXPAND;
+ else if (enter_macro_context (pfile, node))
continue;
- if (m == 2)
- goto next_token;
}
if (token->val.node != pfile->spec_nodes.n__Pragma)
break;
- /* Invalidate controlling macros. */
+ /* Handle it, and get another token. */
pfile->mi_state = MI_FAILED;
_cpp_do__Pragma (pfile);
- goto next_token;
}
}