]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Hide NT_MACRO
authorNathan Sidwell <nathan@acm.org>
Fri, 6 Jul 2018 17:49:52 +0000 (17:49 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Fri, 6 Jul 2018 17:49:52 +0000 (17:49 +0000)
Hide NT_MACRO
libcpp/
* include/cpplib.h (cpp_macro_p): New.
* macro.c (cpp_fun_like_macro_p): Use it.
gcc/c-family/
* c-ada-spec.c (count_ada_macro, store_ada_macro): Use
cpp_macro_p.
* c-ppoutput.c (dump_macro): Likewise.
* c-spellcheck.cc (should_suggest_as_macro_p): Likewise.
gcc/
* config/rs6000/rs6000-c.c (rs6000_macro_to_expand): Use cpp_macro_p.
* config/powerpcspe/powerpcspe-c.c (rs6000_macro_to_expand): Likewise.
gcc/fortran/
* cpp.c (dump_macro): Use cpp_macro_p.

From-SVN: r262483

ChangeLog.name-lookup
gcc/c-family/c-ada-spec.c
gcc/c-family/c-ppoutput.c
gcc/c-family/c-spellcheck.cc
gcc/config/powerpcspe/powerpcspe-c.c
gcc/config/rs6000/rs6000-c.c
gcc/fortran/cpp.c
libcpp/include/cpplib.h
libcpp/macro.c

index 22a99a292d9562a25637b55feecd90b1ee20f42a..03bb9c69848140195b9ee300f3ab95aa6f1e3971 100644 (file)
@@ -1,5 +1,20 @@
 2018-07-06  Nathan Sidwell  <nathan@acm.org>
 
+       Hide NT_MACRO
+       libcpp/
+       * include/cpplib.h (cpp_macro_p): New.
+       * macro.c (cpp_fun_like_macro_p): Use it.
+       gcc/c-family/
+       * c-ada-spec.c (count_ada_macro, store_ada_macro): Use
+       cpp_macro_p.
+       * c-ppoutput.c (dump_macro): Likewise.
+       * c-spellcheck.cc (should_suggest_as_macro_p): Likewise.
+       gcc/
+       * config/rs6000/rs6000-c.c (rs6000_macro_to_expand): Use cpp_macro_p.
+       * config/powerpcspe/powerpcspe-c.c (rs6000_macro_to_expand): Likewise.
+       gcc/fortran/
+       * cpp.c (dump_macro): Use cpp_macro_p.
+
        Merge trunk r262473.
 
        Merge trunk r260623.
index 982b850919e066287bc820182f40c7ccb7c006d2..99b6f0581431a2535573abadc0a1492b72e113c0 100644 (file)
@@ -171,13 +171,12 @@ static int
 count_ada_macro (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *node,
                 void *v ATTRIBUTE_UNUSED)
 {
-  const cpp_macro *macro = node->value.macro;
-
-  if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN)
-      && macro->count
-      && *NODE_NAME (node) != '_'
-      && LOCATION_FILE (macro->line) == macro_source_file)
-    max_ada_macros++;
+  if (cpp_macro_p (node) && *NODE_NAME (node) != '_')
+    {
+      const cpp_macro *macro = node->value.macro;
+      if (macro->count && LOCATION_FILE (macro->line) == macro_source_file)
+       max_ada_macros++;
+    }
 
   return 1;
 }
@@ -190,15 +189,13 @@ static int
 store_ada_macro (cpp_reader *pfile ATTRIBUTE_UNUSED,
                 cpp_hashnode *node, void *macros)
 {
-  const cpp_macro *macro = node->value.macro;
-
-  if (node->type == NT_MACRO
-      && !(node->flags & NODE_BUILTIN)
-      && macro->count
-      && *NODE_NAME (node) != '_'
-      && LOCATION_FILE (macro->line) == macro_source_file)
-    ((cpp_hashnode **) macros)[store_ada_macro_index++] = node;
-
+  if (cpp_macro_p (node) && *NODE_NAME (node) != '_')
+    {
+      const cpp_macro *macro = node->value.macro;
+      if (macro->count
+         && LOCATION_FILE (macro->line) == macro_source_file)
+       ((cpp_hashnode **) macros)[store_ada_macro_index++] = node;
+    }
   return 1;
 }
 
index 8c525caf28daa9e66652a8d9f6e38fe707210583..fb30248e5d0902cec7ba9db4c77a4899994e44b2 100644 (file)
@@ -690,7 +690,7 @@ cb_def_pragma (cpp_reader *pfile, source_location line)
 static int
 dump_macro (cpp_reader *pfile, cpp_hashnode *node, void *v ATTRIBUTE_UNUSED)
 {
-  if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN))
+  if (cpp_macro_p (node))
     {
       fputs ("#define ", print.outf);
       fputs ((const char *) cpp_macro_definition (pfile, node),
index c0975d32ea490116fe78790849c193a62b796d5f..f1da61eb33f0f0309d4fd8d161c5510f51065e28 100644 (file)
@@ -45,13 +45,13 @@ name_reserved_for_implementation_p (const char *str)
 static bool
 should_suggest_as_macro_p (cpp_hashnode *hashnode)
 {
-  if (hashnode->type != NT_MACRO)
+  if (!cpp_macro_p (hashnode, true))
     return false;
 
-  /* Don't suggest names reserved for the implementation, but do suggest the builtin
-     macros such as __FILE__, __LINE__ etc.  */
-  if (name_reserved_for_implementation_p ((const char *)hashnode->ident.str)
-      && !(hashnode->flags & NODE_BUILTIN))
+  /* Don't suggest names reserved for the implementation, but do
+     suggest the builtin macros such as __FILE__, __LINE__ etc.  */
+  if (cpp_macro_p (hashnode, false)
+      && name_reserved_for_implementation_p ((const char *)hashnode->ident.str))
     return false;
 
   return true;
index 157c1853aa45964447c290ade2625a171d6d17de..9b8f698a79ce876a2a9c51820051e9250333c6fa 100644 (file)
@@ -220,21 +220,22 @@ rs6000_macro_to_expand (cpp_reader *pfile, const cpp_token *tok)
       else if (ident && (ident != C_CPP_HASHNODE (__vector_keyword)))
        {
          enum rid rid_code = (enum rid)(ident->rid_code);
-         enum node_type itype = ident->type;
+         bool is_macro = cpp_macro_p (ident, true);
+
          /* If there is a function-like macro, check if it is going to be
             invoked with or without arguments.  Without following ( treat
             it like non-macro, otherwise the following cpp_get_token eats
             what should be preserved.  */
-         if (itype == NT_MACRO && cpp_fun_like_macro_p (ident))
+         if (is_macro && cpp_fun_like_macro_p (ident))
            {
              int idx2 = idx;
              do
                tok = cpp_peek_token (pfile, idx2++);
              while (tok->type == CPP_PADDING);
              if (tok->type != CPP_OPEN_PAREN)
-               itype = NT_VOID;
+               is_macro = false;
            }
-         if (itype == NT_MACRO)
+         if (is_macro)
            {
              do
                (void) cpp_get_token (pfile);
index f37f0b1503d3f0e7e5fa72626d45a629400c8331..02e606c03138e6a8a75f3b703fce2d67a1d37aef 100644 (file)
@@ -220,21 +220,23 @@ rs6000_macro_to_expand (cpp_reader *pfile, const cpp_token *tok)
       else if (ident && (ident != C_CPP_HASHNODE (__vector_keyword)))
        {
          enum rid rid_code = (enum rid)(ident->rid_code);
-         enum node_type itype = ident->type;
+         bool is_macro = cpp_macro_p (ident, true);
+
          /* If there is a function-like macro, check if it is going to be
             invoked with or without arguments.  Without following ( treat
             it like non-macro, otherwise the following cpp_get_token eats
             what should be preserved.  */
-         if (itype == NT_MACRO && cpp_fun_like_macro_p (ident))
+         if (is_macro && cpp_fun_like_macro_p (ident))
            {
              int idx2 = idx;
              do
                tok = cpp_peek_token (pfile, idx2++);
              while (tok->type == CPP_PADDING);
              if (tok->type != CPP_OPEN_PAREN)
-               itype = NT_VOID;
+               is_macro = false;
            }
-         if (itype == NT_MACRO)
+
+         if (is_macro)
            {
              do
                (void) cpp_get_token (pfile);
index 82e890f015c80899897fff232629624d20ba3f51..2b2b89d0c97721a2ce6d1fc94f70fae4c0ea4af8 100644 (file)
@@ -993,7 +993,7 @@ cb_include (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location line,
 static int
 dump_macro (cpp_reader *pfile, cpp_hashnode *node, void *v ATTRIBUTE_UNUSED)
 {
-  if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN))
+  if (cpp_macro_p (node))
     {
       fputs ("#define ", print.outf);
       fputs ((const char *) cpp_macro_definition (pfile, node),
index 3ad52d5e01e5a78a551c937d2cc6dce4c37a0608..d773c9a602b822ef684607ab53324f109d9c8754 100644 (file)
@@ -890,6 +890,11 @@ extern int cpp_avoid_paste (cpp_reader *, const cpp_token *,
 extern const cpp_token *cpp_get_token (cpp_reader *);
 extern const cpp_token *cpp_get_token_with_location (cpp_reader *,
                                                     source_location *);
+inline bool cpp_macro_p (cpp_hashnode *node, bool builtin_ok = false)
+{
+  return (node->type == NT_MACRO
+         && (builtin_ok || !(node->flags & NODE_BUILTIN)));
+}
 extern bool cpp_fun_like_macro_p (cpp_hashnode *);
 extern const unsigned char *cpp_macro_definition (cpp_reader *,
                                                  cpp_hashnode *);
index 776af7bd00eae4f0571f61c36ceaa1a276c256d3..deb7540077991fcb117cdebb66daba06f08834ec 100644 (file)
@@ -3594,9 +3594,7 @@ check_trad_stringification (cpp_reader *pfile, const cpp_macro *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);
+  return cpp_macro_p (node) && node->value.macro->fun_like;
 }
 
 /* Returns the name, arguments and expansion of a macro, in a format