summaryrefslogtreecommitdiff
path: root/gcc/cpplib.c
diff options
context:
space:
mode:
authorneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2001-07-29 17:27:57 +0000
committerneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2001-07-29 17:27:57 +0000
commitfa233610fcbee7f3e67375962e6effe96c2b19e2 (patch)
treeae3bf4ef61f7e71d609b714e200c82e7e441cba2 /gcc/cpplib.c
parent4d1f4307480c700e251e01b4931f8935db4a04cc (diff)
downloadgcc-fa233610fcbee7f3e67375962e6effe96c2b19e2.tar.gz
* cppexp.c (parse_defined): Always record the macro name.
(lex): Don't worry about identifiers, or special-case CPP_NOT here. (_cpp_parse_expr): Figure out at the end of the routine whether we saw a valid !defined() expression. * cppfiles.c (stack_include_file): Update for mi_valid. (_cpp_pop_file_buffer): Similarly. * cpplex.c (_cpp_lex_token): Similarly. * cpphash.h (enum mi_state, enum mi_ind, mi_state, mi_if_not_defined, mi_lexed): Remove. (mi_valid): New. * cpplib.c (do_if): Simplify. (do_endif, push_conditional, _cpp_handle_directive): Update for renaming of mi_state to mi_valid. * cpp.texi: Add index entries for digraphs, and add comment that C++ refers to them as alternative tokens. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44459 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r--gcc/cpplib.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index c196c1f9c96..8f9f54c8be6 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -358,7 +358,7 @@ _cpp_handle_directive (pfile, indented)
/* If we have a directive that is not an opening
conditional, invalidate any control macro. */
if (! (dir->flags & IF_COND))
- pfile->mi_state = MI_FAILED;
+ pfile->mi_valid = false;
(*dir->handler) (pfile);
}
@@ -1278,27 +1278,22 @@ do_ifndef (pfile)
push_conditional (pfile, skip, T_IFNDEF, node);
}
-/* #if cooperates with parse_defined to handle multiple-include
- optimisations. If macro expansions or identifiers appear in the
- expression, we cannot treat it as a controlling conditional, since
- their values could change in the future. */
+/* _cpp_parse_expr puts a macro in a "#if !defined ()" expression in
+ pfile->mi_ind_cmacro so we can handle multiple-include
+ optimisations. If macro expansion occurs in the expression, we
+ cannot treat it as a controlling conditional, since the expansion
+ could change in the future. That is handled by cpp_get_token. */
static void
do_if (pfile)
cpp_reader *pfile;
{
int skip = 1;
- const cpp_hashnode *cmacro = 0;
if (! pfile->state.skipping)
- {
- /* Controlling macro of #if ! defined () */
- pfile->mi_ind_cmacro = 0;
- skip = _cpp_parse_expr (pfile) == 0;
- cmacro = pfile->mi_ind_cmacro;
- }
+ skip = _cpp_parse_expr (pfile) == 0;
- push_conditional (pfile, skip, T_IF, cmacro);
+ push_conditional (pfile, skip, T_IF, pfile->mi_ind_cmacro);
}
/* Flip skipping state if appropriate and continue without changing
@@ -1395,7 +1390,7 @@ do_endif (pfile)
/* If potential control macro, we go back outside again. */
if (ifs->next == 0 && ifs->mi_cmacro)
{
- pfile->mi_state = MI_OUTSIDE;
+ pfile->mi_valid = true;
pfile->mi_cmacro = ifs->mi_cmacro;
}
@@ -1406,8 +1401,8 @@ do_endif (pfile)
}
/* Push an if_stack entry and set pfile->state.skipping accordingly.
- If this is a #ifndef starting at the beginning of a file,
- CMACRO is the macro name tested by the #ifndef. */
+ If this is a #if or #ifndef, CMACRO is a potentially controlling
+ macro - we need to check here that we are at the top of the file. */
static void
push_conditional (pfile, skip, type, cmacro)
@@ -1425,7 +1420,8 @@ push_conditional (pfile, skip, type, cmacro)
ifs->skip_elses = pfile->state.skipping || !skip;
ifs->was_skipping = pfile->state.skipping;
ifs->type = type;
- if (pfile->mi_state == MI_OUTSIDE && pfile->mi_cmacro == 0)
+ /* This condition is effectively a test for top-of-file. */
+ if (pfile->mi_valid && pfile->mi_cmacro == 0)
ifs->mi_cmacro = cmacro;
else
ifs->mi_cmacro = 0;