From 7692e253ee0bdab40fb896991f9208112ebfff61 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 20 Aug 2018 15:28:15 +0000 Subject: [PATCH] [CPP PATCH] Fix warning & other cleanups. https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01162.html * directives.c (do_undef): Use cpp_macro_p & cpp_builtin_macro_p. * include/cpplib.h (enum cpp_macro_kind): Remove trailing comma. (cpp_fun_like_macro_p): Make inline, define. * macro.c (cpp_define_lazily): Use UCHAR_MAX. (cpp_fun_like_macro_p): Delete. From-SVN: r263666 --- libcpp/ChangeLog | 6 ++++++ libcpp/directives.c | 4 ++-- libcpp/include/cpplib.h | 7 +++++-- libcpp/macro.c | 11 +---------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 19d89b17227..01cc2508678 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,5 +1,11 @@ 2018-08-20 Nathan Sidwell + * directives.c (do_undef): Use cpp_macro_p & cpp_builtin_macro_p. + * include/cpplib.h (enum cpp_macro_kind): Remove trailing comma. + (cpp_fun_like_macro_p): Make inline, define. + * macro.c (cpp_define_lazily): Use UCHAR_MAX. + (cpp_fun_like_macro_p): Delete. + * Makefile.in (TAGS_SOURCES): Remove cpp-id-data.h. * include/cpp-id-data.h: Delete. * internal.h: Include cpplib.h not cpp-id-data.h. diff --git a/libcpp/directives.c b/libcpp/directives.c index e75462f1c0d..f04ed7cf2c1 100644 --- a/libcpp/directives.c +++ b/libcpp/directives.c @@ -665,12 +665,12 @@ do_undef (cpp_reader *pfile) /* 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 (cpp_macro_p (node)) { if (node->flags & NODE_WARN) cpp_error (pfile, CPP_DL_WARNING, "undefining \"%s\"", NODE_NAME (node)); - else if ((node->flags & NODE_BUILTIN) + else if (cpp_builtin_macro_p (node) && CPP_OPTION (pfile, warn_builtin_macro_redefined)) cpp_warning_with_line (pfile, CPP_W_BUILTIN_MACRO_REDEFINED, pfile->directive_line, 0, diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index d446fb1e48c..b784e0facd0 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -674,7 +674,7 @@ struct cpp_dir enum cpp_macro_kind { cmk_macro, /* An ISO macro (token expansion). */ cmk_assert, /* An assertion. */ - cmk_traditional, /* A traditional macro (text expansion). */ + cmk_traditional /* A traditional macro (text expansion). */ }; /* Each macro definition is recorded in a cpp_macro structure. @@ -972,7 +972,10 @@ inline bool cpp_macro_p (const cpp_hashnode *node) return node->type == NT_MACRO; } /* Returns true if NODE is a function-like user macro. */ -extern bool cpp_fun_like_macro_p (cpp_hashnode *node); +inline bool cpp_fun_like_macro_p (cpp_hashnode *node) +{ + return cpp_user_macro_p (node) && node->value.macro->fun_like; +} extern const unsigned char *cpp_macro_definition (cpp_reader *, cpp_hashnode *); diff --git a/libcpp/macro.c b/libcpp/macro.c index 0f9e25d3b98..123f63d1177 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -3551,7 +3551,7 @@ cpp_define_lazily (cpp_reader *pfile, cpp_hashnode *node, unsigned num) { cpp_macro *macro = node->value.macro; - gcc_checking_assert (pfile->cb.user_lazy_macro && macro && num < 255); + gcc_checking_assert (pfile->cb.user_lazy_macro && macro && num < UCHAR_MAX); macro->lazy = num + 1; } @@ -3632,15 +3632,6 @@ check_trad_stringification (cpp_reader *pfile, const cpp_macro *macro, } } -/* Returns true of NODE is a function-like macro. */ -bool -cpp_fun_like_macro_p (cpp_hashnode *node) -{ - return (node->type == NT_MACRO - && (node->flags & (NODE_BUILTIN | NODE_MACRO_ARG)) == 0 - && node->value.macro->fun_like); -} - /* Returns the name, arguments and expansion of a macro, in a format suitable to be read back in again, and therefore also for DWARF 2 debugging info. e.g. "PASTE(X, Y) X ## Y", or "MACNAME EXPANSION". -- 2.30.2