[C++] Use INDIRECT_REF_P in a few more places

Message ID 582b472e-64a7-a743-2255-56eb8bb64517@oracle.com
State New
Headers show
Series
  • [C++] Use INDIRECT_REF_P in a few more places
Related show

Commit Message

Paolo Carlini Feb. 8, 2018, 9:19 a.m.
Hi,

yesterday I noticed these and I regression tested the change together 
with my fix for 83204. Can definitely wait, but seems very safe...

Cheers, Paolo.

///////////////////
2018-02-08  Paolo Carlini  <paolo.carlini@oracle.com>

	* constexpr.c (cxx_eval_component_reference): Use INDIRECT_REF_P.
	* lambda.c (build_capture_proxy): Likewise.
	* search.c (field_access_p): Likewise.
	* semantics.c (omp_clause_decl, omp_privatize_field,
	finish_omp_clauses): Likewise.

Comments

Jason Merrill Feb. 8, 2018, 5:36 p.m. | #1
OK.

On Thu, Feb 8, 2018 at 4:19 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> Hi,

>

> yesterday I noticed these and I regression tested the change together with

> my fix for 83204. Can definitely wait, but seems very safe...

>

> Cheers, Paolo.

>

> ///////////////////

>

Patch

Index: constexpr.c
===================================================================
--- constexpr.c	(revision 257438)
+++ constexpr.c	(working copy)
@@ -2463,7 +2463,7 @@  cxx_eval_component_reference (const constexpr_ctx
   tree whole = cxx_eval_constant_expression (ctx, orig_whole,
 					     lval,
 					     non_constant_p, overflow_p);
-  if (TREE_CODE (whole) == INDIRECT_REF
+  if (INDIRECT_REF_P (whole)
       && integer_zerop (TREE_OPERAND (whole, 0))
       && !ctx->quiet)
     error ("dereferencing a null pointer in %qE", orig_whole);
Index: lambda.c
===================================================================
--- lambda.c	(revision 257438)
+++ lambda.c	(working copy)
@@ -450,7 +450,7 @@  build_capture_proxy (tree member, tree init)
 	{
 	  if (PACK_EXPANSION_P (init))
 	    init = PACK_EXPANSION_PATTERN (init);
-	  if (TREE_CODE (init) == INDIRECT_REF)
+	  if (INDIRECT_REF_P (init))
 	    init = TREE_OPERAND (init, 0);
 	  STRIP_NOPS (init);
 	}
Index: search.c
===================================================================
--- search.c	(revision 257438)
+++ search.c	(working copy)
@@ -1636,7 +1636,7 @@  field_access_p (tree component_ref, tree field_dec
     return false;
 
   tree indirect_ref = TREE_OPERAND (component_ref, 0);
-  if (TREE_CODE (indirect_ref) != INDIRECT_REF)
+  if (!INDIRECT_REF_P (indirect_ref))
     return false;
 
   tree ptr = STRIP_NOPS (TREE_OPERAND (indirect_ref, 0));
Index: semantics.c
===================================================================
--- semantics.c	(revision 257438)
+++ semantics.c	(working copy)
@@ -4391,7 +4391,7 @@  omp_clause_decl_field (tree decl)
       && DECL_OMP_PRIVATIZED_MEMBER (decl))
     {
       tree f = DECL_VALUE_EXPR (decl);
-      if (TREE_CODE (f) == INDIRECT_REF)
+      if (INDIRECT_REF_P (f))
 	f = TREE_OPERAND (f, 0);
       if (TREE_CODE (f) == COMPONENT_REF)
 	{
@@ -4446,7 +4446,7 @@  omp_privatize_field (tree t, bool shared)
     omp_private_member_map = new hash_map<tree, tree>;
   if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)
     {
-      gcc_assert (TREE_CODE (m) == INDIRECT_REF);
+      gcc_assert (INDIRECT_REF_P (m));
       m = TREE_OPERAND (m, 0);
     }
   tree vb = NULL_TREE;
@@ -5864,7 +5864,7 @@  finish_omp_clauses (tree clauses, enum c_omp_regio
 		  if (TREE_CODE (t) == POINTER_PLUS_EXPR)
 		    t = TREE_OPERAND (t, 0);
 		  if (TREE_CODE (t) == ADDR_EXPR
-		      || TREE_CODE (t) == INDIRECT_REF)
+		      || INDIRECT_REF_P (t))
 		    t = TREE_OPERAND (t, 0);
 		}
 	      tree n = omp_clause_decl_field (t);