aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2018-08-20 15:28:15 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2018-08-20 15:28:15 +0000
commit7692e253ee0bdab40fb896991f9208112ebfff61 (patch)
treed7d8e0dbf2fb099ed1f39632f6d6f65ebdbd43c4
parente11b709d2107a504c185d75d7e1a2b0b2a2dc6fe (diff)
downloadgcc-7692e253ee0bdab40fb896991f9208112ebfff61.zip
gcc-7692e253ee0bdab40fb896991f9208112ebfff61.tar.gz
gcc-7692e253ee0bdab40fb896991f9208112ebfff61.tar.bz2
[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
-rw-r--r--libcpp/ChangeLog6
-rw-r--r--libcpp/directives.c4
-rw-r--r--libcpp/include/cpplib.h7
-rw-r--r--libcpp/macro.c11
4 files changed, 14 insertions, 14 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 19d89b1..01cc250 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,5 +1,11 @@
2018-08-20 Nathan Sidwell <nathan@acm.org>
+ * 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 e75462f..f04ed7c 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 d446fb1..b784e0f 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 0f9e25d..123f63d 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".