From cb6da767b099d8cb044b255b58ca34ba02e8cd38 Mon Sep 17 00:00:00 2001
From: Gabriel Dos Reis <gdr@integrable-solutions.net>
Date: Tue, 26 Mar 2013 20:05:55 +0000
Subject: [PATCH] cp-gimplify.c (cp_genericize_r): Use VAR_OR_FUNCTION_DECL_P.

	* cp-gimplify.c (cp_genericize_r): Use VAR_OR_FUNCTION_DECL_P.
	* decl.c (duplicate_decls): Likewise.
	(cp_finish_decl): Likewise.
	(check_class_member_definition_namespace): Likewise.
	* decl2.c (grokfield): Likewise.
	(decl_needed_p): Likewise.
	(import_export_decl): Likewise.
	(mark_used): Likewise.
	* name-lookup.c (pushdecl_maybe_friend_1): Likewise.
	* pt.c (push_access_scope): Likewise.
	(instantiate_decl): Likewise.
	* ptree.c (cxx_print_decl): Likewise.
	* repo.c (repo_emit_p): Likewise.
	* semantics.c (note_decl_for_pch): Likewise.
	* tree.c (decl_linkage): Likewise.

From-SVN: r197119
---
 gcc/cp/ChangeLog     | 18 ++++++++++++++++++
 gcc/cp/cp-gimplify.c |  2 +-
 gcc/cp/decl.c        |  9 +++------
 gcc/cp/decl2.c       | 16 ++++++----------
 gcc/cp/name-lookup.c |  2 +-
 gcc/cp/pt.c          |  8 +++-----
 gcc/cp/ptree.c       |  2 +-
 gcc/cp/repo.c        |  3 +--
 gcc/cp/semantics.c   |  3 +--
 gcc/cp/tree.c        |  5 ++---
 10 files changed, 37 insertions(+), 31 deletions(-)

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 01044e493d7d..8bddaf2dfa43 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,21 @@
+2013-03-26  Gabriel Dos Reis  <gdr@integrable-solutions.net>
+
+	* cp-gimplify.c (cp_genericize_r): Use VAR_OR_FUNCTION_DECL_P.
+	* decl.c (duplicate_decls): Likewise.
+	(cp_finish_decl): Likewise.
+	(check_class_member_definition_namespace): Likewise.
+	* decl2.c (grokfield): Likewise.
+	(decl_needed_p): Likewise.
+	(import_export_decl): Likewise.
+	(mark_used): Likewise.
+	* name-lookup.c (pushdecl_maybe_friend_1): Likewise.
+	* pt.c (push_access_scope): Likewise.
+	(instantiate_decl): Likewise.
+	* ptree.c (cxx_print_decl): Likewise.
+	* repo.c (repo_emit_p): Likewise.
+	* semantics.c (note_decl_for_pch): Likewise.
+	* tree.c (decl_linkage): Likewise.
+
 2013-03-26  Paolo Carlini  <paolo.carlini@oracle.com>
 
 	PR c++/55951
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index b2bfd0c1fdc0..765fb2f67da3 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -857,7 +857,7 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
   /* Map block scope extern declarations to visible declarations with the
      same name and type in outer scopes if any.  */
   if (cp_function_chain->extern_decl_map
-      && (TREE_CODE (stmt) == FUNCTION_DECL || TREE_CODE (stmt) == VAR_DECL)
+      && VAR_OR_FUNCTION_DECL_P (stmt)
       && DECL_EXTERNAL (stmt))
     {
       struct cxx_int_tree_map *h, in;
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index ca68bb509bf3..d5e86a05fad5 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1620,8 +1620,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
 	  warning_at (DECL_SOURCE_LOCATION (olddecl), 0,
 		      "follows non-prototype definition here");
 	}
-      else if ((TREE_CODE (olddecl) == FUNCTION_DECL
-		|| TREE_CODE (olddecl) == VAR_DECL)
+      else if (VAR_OR_FUNCTION_DECL_P (olddecl)
 	       && DECL_LANGUAGE (newdecl) != DECL_LANGUAGE (olddecl))
 	{
 	  /* [dcl.link]
@@ -6408,8 +6407,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
 
   /* Let the middle end know about variables and functions -- but not
      static data members in uninstantiated class templates.  */
-  if (TREE_CODE (decl) == VAR_DECL
-      || TREE_CODE (decl) == FUNCTION_DECL)
+  if (VAR_OR_FUNCTION_DECL_P (decl))
     {
       if (TREE_CODE (decl) == VAR_DECL)
 	{
@@ -7230,8 +7228,7 @@ check_class_member_definition_namespace (tree decl)
 {
   /* These checks only apply to member functions and static data
      members.  */
-  gcc_assert (TREE_CODE (decl) == FUNCTION_DECL
-	      || TREE_CODE (decl) == VAR_DECL);
+  gcc_assert (VAR_OR_FUNCTION_DECL_P (decl));
   /* We check for problems with specializations in pt.c in
      check_specialization_namespace, where we can issue better
      diagnostics.  */
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index f13efd67da97..60fad44eecde 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -955,8 +955,7 @@ grokfield (const cp_declarator *declarator,
 	}
     }
 
-  if (processing_template_decl
-      && (TREE_CODE (value) == VAR_DECL || TREE_CODE (value) == FUNCTION_DECL))
+  if (processing_template_decl && VAR_OR_FUNCTION_DECL_P (value))
     {
       value = push_template_decl (value);
       if (error_operand_p (value))
@@ -1799,8 +1798,7 @@ mark_needed (tree decl)
 bool
 decl_needed_p (tree decl)
 {
-  gcc_assert (TREE_CODE (decl) == VAR_DECL
-	      || TREE_CODE (decl) == FUNCTION_DECL);
+  gcc_assert (VAR_OR_FUNCTION_DECL_P (decl));
   /* This function should only be called at the end of the translation
      unit.  We cannot be sure of whether or not something will be
      COMDAT until that point.  */
@@ -2002,8 +2000,7 @@ constrain_visibility_for_template (tree decl, tree targs)
 	  STRIP_NOPS (arg);
 	  if (TREE_CODE (arg) == ADDR_EXPR)
 	    arg = TREE_OPERAND (arg, 0);
-	  if (TREE_CODE (arg) == VAR_DECL
-	      || TREE_CODE (arg) == FUNCTION_DECL)
+	  if (VAR_OR_FUNCTION_DECL_P (arg))
 	    {
 	      if (! TREE_PUBLIC (arg))
 		vis = VISIBILITY_ANON;
@@ -2419,8 +2416,7 @@ import_export_decl (tree decl)
      definition available in this translation unit.
 
      The following assertions check these conditions.  */
-  gcc_assert (TREE_CODE (decl) == FUNCTION_DECL
-	      || TREE_CODE (decl) == VAR_DECL);
+  gcc_assert (VAR_OR_FUNCTION_DECL_P (decl));
   /* Any code that creates entities with TREE_PUBLIC cleared should
      also set DECL_INTERFACE_KNOWN.  */
   gcc_assert (TREE_PUBLIC (decl));
@@ -4528,7 +4524,7 @@ mark_used (tree decl)
   /* We can only check DECL_ODR_USED on variables or functions with
      DECL_LANG_SPECIFIC set, and these are also the only decls that we
      might need special handling for.  */
-  if ((TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FUNCTION_DECL)
+  if (!VAR_OR_FUNCTION_DECL_P (decl)
       || DECL_LANG_SPECIFIC (decl) == NULL
       || DECL_THUNK_P (decl))
     {
@@ -4664,7 +4660,7 @@ mark_used (tree decl)
       /* If this is a synthesized method we don't need to
 	 do the instantiation test below.  */
     }
-  else if ((TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL)
+  else if (VAR_OR_FUNCTION_DECL_P (decl)
 	   && DECL_TEMPLATE_INFO (decl)
 	   && (!DECL_EXPLICIT_INSTANTIATION (decl)
 	       || always_instantiate_p (decl)))
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index dd6ef223def4..0a0915af8a91 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -678,7 +678,7 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend)
 	 block scope declaration declares that same entity and
 	 receives the linkage of the previous declaration.  */
       if (! t && current_function_decl && x != current_function_decl
-	  && (TREE_CODE (x) == FUNCTION_DECL || TREE_CODE (x) == VAR_DECL)
+	  && VAR_OR_FUNCTION_DECL_P (x)
 	  && DECL_EXTERNAL (x))
 	{
 	  /* Look in block scope.  */
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index b6066c18bdea..bb690c5009ff 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -213,9 +213,8 @@ static tree instantiate_alias_template (tree, tree, tsubst_flags_t);
 static void
 push_access_scope (tree t)
 {
-  gcc_assert (TREE_CODE (t) == FUNCTION_DECL
-	      || TREE_CODE (t) == TYPE_DECL
-	      || TREE_CODE (t) == VAR_DECL);
+  gcc_assert (VAR_OR_FUNCTION_DECL_P (t)
+	      || TREE_CODE (t) == TYPE_DECL);
 
   if (DECL_FRIEND_CONTEXT (t))
     push_nested_class (DECL_FRIEND_CONTEXT (t));
@@ -18598,8 +18597,7 @@ instantiate_decl (tree d, int defer_ok,
 
   /* This function should only be used to instantiate templates for
      functions and static member variables.  */
-  gcc_assert (TREE_CODE (d) == FUNCTION_DECL
-	      || TREE_CODE (d) == VAR_DECL);
+  gcc_assert (VAR_OR_FUNCTION_DECL_P (d));
 
   /* Variables are never deferred; if instantiation is required, they
      are instantiated right away.  That allows for better code in the
diff --git a/gcc/cp/ptree.c b/gcc/cp/ptree.c
index deba90fd488f..f4ca003be983 100644
--- a/gcc/cp/ptree.c
+++ b/gcc/cp/ptree.c
@@ -63,7 +63,7 @@ cxx_print_decl (FILE *file, tree node, int indent)
       && DECL_PENDING_INLINE_INFO (node))
     fprintf (file, " pending-inline-info %p",
 	     (void *) DECL_PENDING_INLINE_INFO (node));
-  if ((TREE_CODE (node) == FUNCTION_DECL || TREE_CODE (node) == VAR_DECL)
+  if (VAR_OR_FUNCTION_DECL_P (node)
       && DECL_TEMPLATE_INFO (node))
     fprintf (file, " template-info %p",
 	     (void *) DECL_TEMPLATE_INFO (node));
diff --git a/gcc/cp/repo.c b/gcc/cp/repo.c
index 8b9f73f223ad..8c524adbf2b2 100644
--- a/gcc/cp/repo.c
+++ b/gcc/cp/repo.c
@@ -291,8 +291,7 @@ repo_emit_p (tree decl)
 {
   int ret = 0;
   gcc_assert (TREE_PUBLIC (decl));
-  gcc_assert (TREE_CODE (decl) == FUNCTION_DECL
-	      || TREE_CODE (decl) == VAR_DECL);
+  gcc_assert (VAR_OR_FUNCTION_DECL_P (decl));
   gcc_assert (!DECL_REALLY_EXTERN (decl));
 
   /* When not using the repository, emit everything.  */
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 127e2da016c0..333980e88e7a 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2771,8 +2771,7 @@ note_decl_for_pch (tree decl)
 
   /* There's a good chance that we'll have to mangle names at some
      point, even if only for emission in debugging information.  */
-  if ((TREE_CODE (decl) == VAR_DECL
-       || TREE_CODE (decl) == FUNCTION_DECL)
+  if (VAR_OR_FUNCTION_DECL_P (decl)
       && !processing_template_decl)
     mangle_decl (decl);
 }
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 3cfc8690d897..0306db10770b 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -3579,8 +3579,7 @@ decl_linkage (tree decl)
      template instantiations have internal linkage (in the object
      file), but the symbols should still be treated as having external
      linkage from the point of view of the language.  */
-  if ((TREE_CODE (decl) == FUNCTION_DECL
-       || TREE_CODE (decl) == VAR_DECL)
+  if (VAR_OR_FUNCTION_DECL_P (decl)
       && DECL_COMDAT (decl))
     return lk_external;
 
@@ -3594,7 +3593,7 @@ decl_linkage (tree decl)
      really meant to have internal linkage have DECL_THIS_STATIC set.  */
   if (TREE_CODE (decl) == TYPE_DECL)
     return lk_external;
-  if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)
+  if (VAR_OR_FUNCTION_DECL_P (decl))
     {
       if (!DECL_THIS_STATIC (decl))
 	return lk_external;
-- 
GitLab