aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplib.c
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.co.uk>2003-12-12 07:00:29 +0000
committerNeil Booth <neil@gcc.gnu.org>2003-12-12 07:00:29 +0000
commit45f2492c99625b7dff5e9eced1969861d3fc1ca1 (patch)
tree4614d26a7b81e6a3878d634b99ee0a34b5e069e1 /gcc/cpplib.c
parentd2b6eb76fa7c35f512f8f8dd16b027a525550460 (diff)
downloadgcc-45f2492c99625b7dff5e9eced1969861d3fc1ca1.zip
gcc-45f2492c99625b7dff5e9eced1969861d3fc1ca1.tar.gz
gcc-45f2492c99625b7dff5e9eced1969861d3fc1ca1.tar.bz2
PR preprocessor/12935 preprocessor/12952 preprocessor/13046
PR preprocessor/12935 preprocessor/12952 preprocessor/13046 * cpplib.c (prepare_directive_trad): Clear skipping only in #if and #elif directives. (do_undef): Call the handler even if the identifier is not a macro. * cpptrad.c (scan_parameters): Emit an error message. (_cpp_create_trad_definition): Remember the params list even on failure. * testsuite/gcc.dg/cpp/trad/macro.c: New tests. From-SVN: r74562
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r--gcc/cpplib.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index 69995d4..2b213cb 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -272,14 +272,17 @@ prepare_directive_trad (cpp_reader *pfile)
&& ! (pfile->directive->flags & EXPAND));
bool was_skipping = pfile->state.skipping;
- pfile->state.skipping = false;
pfile->state.in_expression = (pfile->directive == &dtable[T_IF]
|| pfile->directive == &dtable[T_ELIF]);
+ if (pfile->state.in_expression)
+ pfile->state.skipping = false;
+
if (no_expand)
pfile->state.prevent_expansion++;
_cpp_scan_out_logical_line (pfile, NULL);
if (no_expand)
pfile->state.prevent_expansion--;
+
pfile->state.skipping = was_skipping;
_cpp_overlay_buffer (pfile, pfile->out.base,
pfile->out.cur - pfile->out.base);
@@ -520,22 +523,26 @@ do_undef (cpp_reader *pfile)
{
cpp_hashnode *node = lex_macro_node (pfile);
- /* 6.10.3.5 paragraph 2: [#undef] is ignored if the specified identifier
- is not currently defined as a macro name. */
- if (node && node->type == NT_MACRO)
+ if (node)
{
if (pfile->cb.undef)
pfile->cb.undef (pfile, pfile->directive_line, node);
- if (node->flags & NODE_WARN)
- cpp_error (pfile, CPP_DL_WARNING,
- "undefining \"%s\"", NODE_NAME (node));
+ /* 6.10.3.5 paragraph 2: [#undef] is ignored if the specified
+ identifier is not currently defined as a macro name. */
+ if (node->type == NT_MACRO)
+ {
+ if (node->flags & NODE_WARN)
+ cpp_error (pfile, CPP_DL_WARNING,
+ "undefining \"%s\"", NODE_NAME (node));
- if (CPP_OPTION (pfile, warn_unused_macros))
- _cpp_warn_if_unused_macro (pfile, node, NULL);
+ if (CPP_OPTION (pfile, warn_unused_macros))
+ _cpp_warn_if_unused_macro (pfile, node, NULL);
- _cpp_free_definition (node);
+ _cpp_free_definition (node);
+ }
}
+
check_eol (pfile);
}