diff mbox series

[CPP] Fix warning & other cleanups.

Message ID 8132c4c3-55ab-c497-ebc1-f6586293b2f7@acm.org
State New
Headers show
Series [CPP] Fix warning & other cleanups. | expand

Commit Message

Nathan Sidwell Aug. 20, 2018, 3:27 p.m. UTC
I noticed I'd inadvertently allowed a trailing comma to creep in, 
leading to annoying warnings.  I'd also missed a few uses of the 
cpp_macro_p function and friends.  Plus Bernhard had suggested there's a 
name for 255 when it's encoding unsigned char range.

Fixed thusly.

nathan
diff mbox series

Patch

Index: directives.c
===================================================================
--- directives.c	(revision 263658)
+++ directives.c	(working copy)
@@ -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,
Index: include/cpplib.h
===================================================================
--- include/cpplib.h	(revision 263658)
+++ include/cpplib.h	(working copy)
@@ -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_hashn
   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 *);
Index: macro.c
===================================================================
--- macro.c	(revision 263658)
+++ macro.c	(working copy)
@@ -3551,7 +3551,7 @@  cpp_define_lazily (cpp_reader *pfile, cp
 {
   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 *
     }
 }
 
-/* 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".