+2003-12-12 Neil Booth <neil@daikokuya.co.uk>
+
+ 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.
+
2003-12-11 Zack Weinberg <zack@codesourcery.com>
* arm.c (ARM_ADDRESS_COST, THUMB_ADDRESS_COST): Convert macros
&& ! (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);
{
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);
}
break;
}
+ if (!ok)
+ cpp_error (pfile, CPP_DL_ERROR, "syntax error in macro parameter list");
+
CUR (pfile->context) = cur + (*cur == ')');
return ok;
/* Is this a function-like macro? */
if (* CUR (context) == '(')
{
+ bool ok = scan_parameters (pfile, macro);
+
+ /* Remember the params so we can clear NODE_MACRO_ARG flags. */
+ macro->params = (cpp_hashnode **) BUFF_FRONT (pfile->a_buff);
+
/* Setting macro to NULL indicates an error occurred, and
prevents unnecessary work in _cpp_scan_out_logical_line. */
- if (!scan_parameters (pfile, macro))
+ if (!ok)
macro = NULL;
else
{
- /* Success. Commit the parameter array. */
- macro->params = (cpp_hashnode **) BUFF_FRONT (pfile->a_buff);
BUFF_FRONT (pfile->a_buff) = (uchar *) ¯o->params[macro->paramc];
macro->fun_like = 1;
}