static unsigned int read_flag (cpp_reader *, unsigned int);
static int strtoul_for_line (const uchar *, unsigned int, unsigned long *);
static void do_diagnostic (cpp_reader *, int, int);
-static cpp_hashnode *lex_macro_node (cpp_reader *);
+static cpp_hashnode *lex_macro_node (cpp_reader *, bool);
static int undefine_macros (cpp_reader *, cpp_hashnode *, void *);
static void do_include_common (cpp_reader *, enum include_type);
static struct pragma_entry *lookup_pragma_entry (struct pragma_entry *,
}
/* Checks for validity the macro name in #define, #undef, #ifdef and
- #ifndef directives. */
+ #ifndef directives. IS_DEF_OR_UNDEF is true if this call is
+ processing a #define or #undefine directive, and false
+ otherwise. */
static cpp_hashnode *
-lex_macro_node (cpp_reader *pfile)
+lex_macro_node (cpp_reader *pfile, bool is_def_or_undef)
{
const cpp_token *token = _cpp_lex_token (pfile);
{
cpp_hashnode *node = token->val.node;
- if (node == pfile->spec_nodes.n_defined)
+ if (is_def_or_undef && node == pfile->spec_nodes.n_defined)
cpp_error (pfile, CPP_DL_ERROR,
"\"defined\" cannot be used as a macro name");
else if (! (node->flags & NODE_POISONED))
static void
do_define (cpp_reader *pfile)
{
- cpp_hashnode *node = lex_macro_node (pfile);
+ cpp_hashnode *node = lex_macro_node (pfile, true);
if (node)
{
static void
do_undef (cpp_reader *pfile)
{
- cpp_hashnode *node = lex_macro_node (pfile);
+ cpp_hashnode *node = lex_macro_node (pfile, true);
if (node)
{
if (! pfile->state.skipping)
{
- const cpp_hashnode *node = lex_macro_node (pfile);
+ const cpp_hashnode *node = lex_macro_node (pfile, false);
if (node)
{
if (! pfile->state.skipping)
{
- node = lex_macro_node (pfile);
+ node = lex_macro_node (pfile, false);
if (node)
{