[PATCH] Use VAR_P (x) instead of TREE_CODE () == VAR_DECL in fortran FE

Jakub Jelinek jakub@redhat.com
Mon Oct 24 14:48:00 GMT 2016


Hi!

This is a small cleanup patch, use VAR_P or VAR_OR_FUNCTION_DECL_P
macros some more (similar patch has been done for gcc/ directory a few weeks
ago).  Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2016-10-24  Jakub Jelinek  <jakub@redhat.com>

	* trans-intrinsic.c (gfc_conv_intrinsic_minmax): Use VAR_P (x)
	instead of TREE_CODE (x) == VAR_DECL.
	* trans-expr.c (gfc_class_vptr_get, gfc_class_len_get,
	gfc_class_len_or_zero_get, gfc_get_vptr_from_expr,
	gfc_conv_string_length, conv_base_obj_fcn_val,
	gfc_conv_procedure_call, gfc_trans_assignment_1): Likewise.
	* trans-openmp.c (gfc_omp_predetermined_sharing,
	gfc_omp_disregard_value_expr, gfc_omp_private_debug_clause,
	gfc_trans_omp_atomic, gfc_trans_omp_do): Likewise.
	* trans-io.c (nml_get_addr_expr): Likewise.
	* trans-decl.c (gfc_finish_decl, gfc_build_qualified_array,
	gfc_get_symbol_decl, gfc_get_fake_result_decl,
	gfc_trans_deferred_vars, gfc_trans_use_stmts,
	generate_local_decl): Likewise.
	* trans-array.c (trans_array_constructor, trans_array_bound_check,
	build_class_array_ref, gfc_array_init_size,
	gfc_trans_auto_array_allocation, gfc_trans_g77_array,
	gfc_trans_dummy_array_bias, gfc_alloc_allocatable_for_assignment,
	gfc_trans_deferred_array): Likewise.
	* trans.c (gfc_build_array_ref): Likewise.  Use
	VAR_OR_FUNCTION_DECL_P (x) instead of TREE_CODE (x) == VAR_DECL
	|| TREE_CODE (x) == FUNCTION_DECL.

--- gcc/fortran/trans-intrinsic.c.jj	2016-10-14 12:31:58.184681029 +0200
+++ gcc/fortran/trans-intrinsic.c	2016-10-24 14:19:07.388552971 +0200
@@ -3653,7 +3653,7 @@ gfc_conv_intrinsic_minmax (gfc_se * se,
   if (TREE_TYPE (args[0]) != type)
     args[0] = convert (type, args[0]);
   /* Only evaluate the argument once.  */
-  if (TREE_CODE (args[0]) != VAR_DECL && !TREE_CONSTANT (args[0]))
+  if (!VAR_P (args[0]) && !TREE_CONSTANT (args[0]))
     args[0] = gfc_evaluate_now (args[0], &se->pre);
 
   mvar = gfc_create_var (type, "M");
@@ -3677,7 +3677,7 @@ gfc_conv_intrinsic_minmax (gfc_se * se,
 	cond = NULL_TREE;
 
 	/* Only evaluate the argument once.  */
-	if (TREE_CODE (val) != VAR_DECL && !TREE_CONSTANT (val))
+	if (!VAR_P (val) && !TREE_CONSTANT (val))
 	  val = gfc_evaluate_now (val, &se->pre);
       }
 
--- gcc/fortran/trans-expr.c.jj	2016-10-24 10:26:03.605752746 +0200
+++ gcc/fortran/trans-expr.c	2016-10-24 14:18:45.094834107 +0200
@@ -198,7 +198,7 @@ gfc_class_vptr_get (tree decl)
   tree vptr;
   /* For class arrays decl may be a temporary descriptor handle, the vptr is
      then available through the saved descriptor.  */
-  if (TREE_CODE (decl) == VAR_DECL && DECL_LANG_SPECIFIC (decl)
+  if (VAR_P (decl) && DECL_LANG_SPECIFIC (decl)
       && GFC_DECL_SAVED_DESCRIPTOR (decl))
     decl = GFC_DECL_SAVED_DESCRIPTOR (decl);
   if (POINTER_TYPE_P (TREE_TYPE (decl)))
@@ -217,7 +217,7 @@ gfc_class_len_get (tree decl)
   tree len;
   /* For class arrays decl may be a temporary descriptor handle, the len is
      then available through the saved descriptor.  */
-  if (TREE_CODE (decl) == VAR_DECL && DECL_LANG_SPECIFIC (decl)
+  if (VAR_P (decl) && DECL_LANG_SPECIFIC (decl)
       && GFC_DECL_SAVED_DESCRIPTOR (decl))
     decl = GFC_DECL_SAVED_DESCRIPTOR (decl);
   if (POINTER_TYPE_P (TREE_TYPE (decl)))
@@ -239,7 +239,7 @@ gfc_class_len_or_zero_get (tree decl)
   tree len;
   /* For class arrays decl may be a temporary descriptor handle, the vptr is
      then available through the saved descriptor.  */
-  if (TREE_CODE (decl) == VAR_DECL && DECL_LANG_SPECIFIC (decl)
+  if (VAR_P (decl) && DECL_LANG_SPECIFIC (decl)
       && GFC_DECL_SAVED_DESCRIPTOR (decl))
     decl = GFC_DECL_SAVED_DESCRIPTOR (decl);
   if (POINTER_TYPE_P (TREE_TYPE (decl)))
@@ -485,8 +485,7 @@ gfc_get_vptr_from_expr (tree expr)
 	  else
 	    type = NULL_TREE;
 	}
-      if (TREE_CODE (tmp) == VAR_DECL
-	  || TREE_CODE (tmp) == PARM_DECL)
+      if (VAR_P (tmp) || TREE_CODE (tmp) == PARM_DECL)
 	break;
     }
 
@@ -2181,9 +2180,7 @@ gfc_conv_string_length (gfc_charlen * cl
 
   gfc_init_se (&se, NULL);
 
-  if (!cl->length
-	&& cl->backend_decl
-	&& TREE_CODE (cl->backend_decl) == VAR_DECL)
+  if (!cl->length && cl->backend_decl && VAR_P (cl->backend_decl))
     return;
 
   /* If cl->length is NULL, use gfc_conv_expr to obtain the string length but
@@ -3685,7 +3682,7 @@ conv_base_obj_fcn_val (gfc_se * se, tree
   gfc_ref *ref;
   tree var;
 
-  if (TREE_CODE (base_object) != VAR_DECL)
+  if (!VAR_P (base_object))
     {
       var = gfc_create_var (TREE_TYPE (base_object), NULL);
       gfc_add_modify (&se->pre, var, base_object);
@@ -5696,8 +5693,7 @@ gfc_conv_procedure_call (gfc_se * se, gf
 	  else
 	    {
 	      tmp = parmse.string_length;
-	      if (TREE_CODE (tmp) != VAR_DECL
-		  && TREE_CODE (tmp) != COMPONENT_REF)
+	      if (!VAR_P (tmp) && TREE_CODE (tmp) != COMPONENT_REF)
 		tmp = gfc_evaluate_now (parmse.string_length, &se->pre);
 	      parmse.string_length = gfc_build_addr_expr (NULL_TREE, tmp);
 	    }
@@ -6040,7 +6036,7 @@ gfc_conv_procedure_call (gfc_se * se, gf
       if (ts.type == BT_CHARACTER && ts.deferred)
 	{
 	  tmp = len;
-	  if (TREE_CODE (tmp) != VAR_DECL)
+	  if (!VAR_P (tmp))
 	    tmp = gfc_evaluate_now (len, &se->pre);
 	  TREE_STATIC (tmp) = 1;
 	  gfc_add_modify (&se->pre, tmp,
@@ -9713,7 +9709,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1
 
   /* Stabilize a string length for temporaries.  */
   if (expr2->ts.type == BT_CHARACTER && !expr1->ts.deferred
-      && !(TREE_CODE (rse.string_length) == VAR_DECL
+      && !(VAR_P (rse.string_length)
 	   || TREE_CODE (rse.string_length) == PARM_DECL
 	   || TREE_CODE (rse.string_length) == INDIRECT_REF))
     string_length = gfc_evaluate_now (rse.string_length, &rse.pre);
--- gcc/fortran/trans-openmp.c.jj	2016-09-27 09:51:54.805178452 +0200
+++ gcc/fortran/trans-openmp.c	2016-10-24 14:20:17.940663269 +0200
@@ -143,9 +143,7 @@ gfc_omp_predetermined_sharing (tree decl
      variables at all (they can't be redefined), but they can nevertheless appear
      in parallel/task regions and for default(none) purposes treat them as shared.
      For vtables likely the same handling is desirable.  */
-  if (TREE_CODE (decl) == VAR_DECL
-      && TREE_READONLY (decl)
-      && TREE_STATIC (decl))
+  if (VAR_P (decl) && TREE_READONLY (decl) && TREE_STATIC (decl))
     return OMP_CLAUSE_DEFAULT_SHARED;
 
   return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
@@ -1156,7 +1154,7 @@ gfc_omp_disregard_value_expr (tree decl,
       tree value = DECL_VALUE_EXPR (decl);
 
       if (TREE_CODE (value) == COMPONENT_REF
-	  && TREE_CODE (TREE_OPERAND (value, 0)) == VAR_DECL
+	  && VAR_P (TREE_OPERAND (value, 0))
 	  && GFC_DECL_COMMON_OR_EQUIV (TREE_OPERAND (value, 0)))
 	{
 	  /* If variable in COMMON or EQUIVALENCE is privatized, return
@@ -1192,7 +1190,7 @@ gfc_omp_private_debug_clause (tree decl,
       tree value = DECL_VALUE_EXPR (decl);
 
       if (TREE_CODE (value) == COMPONENT_REF
-	  && TREE_CODE (TREE_OPERAND (value, 0)) == VAR_DECL
+	  && VAR_P (TREE_OPERAND (value, 0))
 	  && GFC_DECL_COMMON_OR_EQUIV (TREE_OPERAND (value, 0)))
 	return shared;
     }
@@ -3001,7 +2999,7 @@ gfc_trans_omp_atomic (gfc_code *code)
   lhsaddr = save_expr (lhsaddr);
   if (TREE_CODE (lhsaddr) != SAVE_EXPR
       && (TREE_CODE (lhsaddr) != ADDR_EXPR
-	  || TREE_CODE (TREE_OPERAND (lhsaddr, 0)) != VAR_DECL))
+	  || !VAR_P (TREE_OPERAND (lhsaddr, 0))))
     {
       /* Make sure LHS is simple enough so that goa_lhs_expr_p can recognize
 	 it even after unsharing function body.  */
@@ -3233,7 +3231,7 @@ gfc_trans_omp_do (gfc_code *code, gfc_ex
       dovar_decl = dovar;
 
       /* Special case simple loops.  */
-      if (TREE_CODE (dovar) == VAR_DECL)
+      if (VAR_P (dovar))
 	{
 	  if (integer_onep (step))
 	    simple = 1;
--- gcc/fortran/trans-io.c.jj	2016-10-17 08:42:35.553522430 +0200
+++ gcc/fortran/trans-io.c	2016-10-24 14:19:39.708145403 +0200
@@ -1573,10 +1573,10 @@ nml_get_addr_expr (gfc_symbol * sym, gfc
   else
     decl = c->backend_decl;
 
-  gcc_assert (decl && ((TREE_CODE (decl) == FIELD_DECL
-		     || TREE_CODE (decl) == VAR_DECL
-		     || TREE_CODE (decl) == PARM_DECL)
-		     || TREE_CODE (decl) == COMPONENT_REF));
+  gcc_assert (decl && (TREE_CODE (decl) == FIELD_DECL
+		       || VAR_P (decl)
+		       || TREE_CODE (decl) == PARM_DECL
+		       || TREE_CODE (decl) == COMPONENT_REF));
 
   tmp = decl;
 
--- gcc/fortran/trans-decl.c.jj	2016-09-26 12:06:44.936797646 +0200
+++ gcc/fortran/trans-decl.c	2016-10-24 14:17:43.244614073 +0200
@@ -495,7 +495,7 @@ gfc_finish_decl (tree decl)
   gcc_assert (TREE_CODE (decl) == PARM_DECL
 	      || DECL_INITIAL (decl) == NULL_TREE);
 
-  if (TREE_CODE (decl) != VAR_DECL)
+  if (!VAR_P (decl))
     return;
 
   if (DECL_SIZE (decl) == NULL_TREE
@@ -1020,7 +1020,7 @@ gfc_build_qualified_array (tree decl, gf
 
   if (TYPE_NAME (type) != NULL_TREE
       && GFC_TYPE_ARRAY_UBOUND (type, as->rank - 1) != NULL_TREE
-      && TREE_CODE (GFC_TYPE_ARRAY_UBOUND (type, as->rank - 1)) == VAR_DECL)
+      && VAR_P (GFC_TYPE_ARRAY_UBOUND (type, as->rank - 1)))
     {
       tree gtype = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
 
@@ -1050,8 +1050,10 @@ gfc_build_qualified_array (tree decl, gf
 	     can be tracked by VTA.  Also set DECL_NAMELESS, so that
 	     the artificial lbound.N or ubound.N DECL_NAME doesn't
 	     end up in debug info.  */
-	  if (lbound && TREE_CODE (lbound) == VAR_DECL
-	      && DECL_ARTIFICIAL (lbound) && DECL_IGNORED_P (lbound))
+	  if (lbound
+	      && VAR_P (lbound)
+	      && DECL_ARTIFICIAL (lbound)
+	      && DECL_IGNORED_P (lbound))
 	    {
 	      if (DECL_NAME (lbound)
 		  && strstr (IDENTIFIER_POINTER (DECL_NAME (lbound)),
@@ -1059,8 +1061,10 @@ gfc_build_qualified_array (tree decl, gf
 		DECL_NAMELESS (lbound) = 1;
 	      DECL_IGNORED_P (lbound) = 0;
 	    }
-	  if (ubound && TREE_CODE (ubound) == VAR_DECL
-	      && DECL_ARTIFICIAL (ubound) && DECL_IGNORED_P (ubound))
+	  if (ubound
+	      && VAR_P (ubound)
+	      && DECL_ARTIFICIAL (ubound)
+	      && DECL_IGNORED_P (ubound))
 	    {
 	      if (DECL_NAME (ubound)
 		  && strstr (IDENTIFIER_POINTER (DECL_NAME (ubound)),
@@ -1514,8 +1518,7 @@ gfc_get_symbol_decl (gfc_symbol * sym)
 	    length = gfc_create_string_length (sym);
 	  else
 	    length = sym->ts.u.cl->backend_decl;
-	  if (TREE_CODE (length) == VAR_DECL
-	      && DECL_FILE_SCOPE_P (length))
+	  if (VAR_P (length) && DECL_FILE_SCOPE_P (length))
 	    {
 	      /* Add the string length to the same context as the symbol.  */
 	      if (DECL_CONTEXT (sym->backend_decl) == current_function_decl)
@@ -1630,7 +1633,7 @@ gfc_get_symbol_decl (gfc_symbol * sym)
     {
       if (sym->attr.associate_var
 	  && sym->ts.u.cl->backend_decl
-	  && TREE_CODE (sym->ts.u.cl->backend_decl) == VAR_DECL)
+	  && VAR_P (sym->ts.u.cl->backend_decl))
 	length = gfc_index_zero_node;
       else
 	length = gfc_create_string_length (sym);
@@ -2924,8 +2927,7 @@ gfc_get_fake_result_decl (gfc_symbol * s
 	length = gfc_create_string_length (sym);
       else
 	length = sym->ts.u.cl->backend_decl;
-      if (TREE_CODE (length) == VAR_DECL
-	  && DECL_CONTEXT (length) == NULL_TREE)
+      if (VAR_P (length) && DECL_CONTEXT (length) == NULL_TREE)
 	gfc_add_decl_to_function (length);
     }
 
@@ -4123,7 +4125,7 @@ gfc_trans_deferred_vars (gfc_symbol * pr
 
 	  /* An automatic character length, pointer array result.  */
 	  if (proc_sym->ts.type == BT_CHARACTER
-		&& TREE_CODE (proc_sym->ts.u.cl->backend_decl) == VAR_DECL)
+	      && VAR_P (proc_sym->ts.u.cl->backend_decl))
 	    {
 	      tmp = NULL;
 	      if (proc_sym->ts.deferred)
@@ -4176,7 +4178,7 @@ gfc_trans_deferred_vars (gfc_symbol * pr
 
 	      gfc_add_init_cleanup (block, gfc_finish_block (&init), tmp);
 	    }
-	  else if (TREE_CODE (proc_sym->ts.u.cl->backend_decl) == VAR_DECL)
+	  else if (VAR_P (proc_sym->ts.u.cl->backend_decl))
 	    gfc_trans_dummy_character (proc_sym, proc_sym->ts.u.cl, block);
 	}
       else
@@ -4843,8 +4845,7 @@ gfc_trans_use_stmts (gfc_namespace * ns)
 		  && strcmp (st->n.sym->module, use_stmt->module_name) == 0)
 		{
 		  gcc_assert (DECL_EXTERNAL (entry->namespace_decl)
-			      || (TREE_CODE (st->n.sym->backend_decl)
-				  != VAR_DECL));
+			      || !VAR_P (st->n.sym->backend_decl));
 		  decl = copy_node (st->n.sym->backend_decl);
 		  DECL_CONTEXT (decl) = entry->namespace_decl;
 		  DECL_EXTERNAL (decl) = 1;
@@ -5385,7 +5386,7 @@ generate_local_decl (gfc_symbol * sym)
       if (sym->attr.dummy && !sym->attr.referenced
 	    && sym->ts.type == BT_CHARACTER
 	    && sym->ts.u.cl->backend_decl != NULL
-	    && TREE_CODE (sym->ts.u.cl->backend_decl) == VAR_DECL)
+	    && VAR_P (sym->ts.u.cl->backend_decl))
 	{
 	  sym->attr.referenced = 1;
 	  gfc_get_symbol_decl (sym);
--- gcc/fortran/trans-array.c.jj	2016-10-22 18:57:49.903341774 +0200
+++ gcc/fortran/trans-array.c	2016-10-24 14:15:18.392440741 +0200
@@ -2373,7 +2373,7 @@ trans_array_constructor (gfc_ss * ss, lo
 			     offsetvar, gfc_index_one_node);
       tmp = gfc_evaluate_now (tmp, &outer_loop->pre);
       gfc_conv_descriptor_ubound_set (&loop->pre, desc, gfc_rank_cst[0], tmp);
-      if (*loop_ubound0 && TREE_CODE (*loop_ubound0) == VAR_DECL)
+      if (*loop_ubound0 && VAR_P (*loop_ubound0))
 	gfc_add_modify (&outer_loop->pre, *loop_ubound0, tmp);
       else
 	*loop_ubound0 = tmp;
@@ -2860,7 +2860,7 @@ trans_array_bound_check (gfc_se * se, gf
   name = ss->info->expr->symtree->n.sym->name;
   gcc_assert (name != NULL);
 
-  if (TREE_CODE (descriptor) == VAR_DECL)
+  if (VAR_P (descriptor))
     name = IDENTIFIER_POINTER (DECL_NAME (descriptor));
 
   /* If upper bound is present, include both bounds in the error message.  */
@@ -3104,7 +3104,7 @@ build_class_array_ref (gfc_se *se, tree
 	      else
 		type = NULL_TREE;
 	    }
-	  if (TREE_CODE (tmp) == VAR_DECL)
+	  if (VAR_P (tmp))
 	    break;
 	}
 
@@ -5096,8 +5096,9 @@ gfc_array_init_size (tree descriptor, in
 
   /* Set the dtype before the alloc, because registration of coarrays needs
      it initialized.  */
-  if (expr->ts.type == BT_CHARACTER && expr->ts.deferred
-      && TREE_CODE (expr->ts.u.cl->backend_decl) == VAR_DECL)
+  if (expr->ts.type == BT_CHARACTER
+      && expr->ts.deferred
+      && VAR_P (expr->ts.u.cl->backend_decl))
     {
       type = gfc_typenode_for_spec (&expr->ts);
       tmp = gfc_conv_descriptor_dtype (descriptor);
@@ -5968,7 +5969,7 @@ gfc_trans_auto_array_allocation (tree de
   /* Don't actually allocate space for Cray Pointees.  */
   if (sym->attr.cray_pointee)
     {
-      if (TREE_CODE (GFC_TYPE_ARRAY_OFFSET (type)) == VAR_DECL)
+      if (VAR_P (GFC_TYPE_ARRAY_OFFSET (type)))
 	gfc_add_modify (&init, GFC_TYPE_ARRAY_OFFSET (type), offset);
 
       gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE);
@@ -6001,7 +6002,7 @@ gfc_trans_auto_array_allocation (tree de
     }
 
   /* Set offset of the array.  */
-  if (TREE_CODE (GFC_TYPE_ARRAY_OFFSET (type)) == VAR_DECL)
+  if (VAR_P (GFC_TYPE_ARRAY_OFFSET (type)))
     gfc_add_modify (&init, GFC_TYPE_ARRAY_OFFSET (type), offset);
 
   /* Automatic arrays should not have initializers.  */
@@ -6054,14 +6055,14 @@ gfc_trans_g77_array (gfc_symbol * sym, g
   gfc_start_block (&init);
 
   if (sym->ts.type == BT_CHARACTER
-      && TREE_CODE (sym->ts.u.cl->backend_decl) == VAR_DECL)
+      && VAR_P (sym->ts.u.cl->backend_decl))
     gfc_conv_string_length (sym->ts.u.cl, NULL, &init);
 
   /* Evaluate the bounds of the array.  */
   gfc_trans_array_bounds (type, sym, &offset, &init);
 
   /* Set the offset.  */
-  if (TREE_CODE (GFC_TYPE_ARRAY_OFFSET (type)) == VAR_DECL)
+  if (VAR_P (GFC_TYPE_ARRAY_OFFSET (type)))
     gfc_add_modify (&init, GFC_TYPE_ARRAY_OFFSET (type), offset);
 
   /* Set the pointer itself if we aren't using the parameter directly.  */
@@ -6160,7 +6161,7 @@ gfc_trans_dummy_array_bias (gfc_symbol *
   gfc_start_block (&init);
 
   if (sym->ts.type == BT_CHARACTER
-      && TREE_CODE (sym->ts.u.cl->backend_decl) == VAR_DECL)
+      && VAR_P (sym->ts.u.cl->backend_decl))
     gfc_conv_string_length (sym->ts.u.cl, NULL, &init);
 
   checkparm = (as->type == AS_EXPLICIT
@@ -6384,7 +6385,7 @@ gfc_trans_dummy_array_bias (gfc_symbol *
   gfc_trans_array_cobounds (type, &init, sym);
 
   /* Set the offset.  */
-  if (TREE_CODE (GFC_TYPE_ARRAY_OFFSET (type)) == VAR_DECL)
+  if (VAR_P (GFC_TYPE_ARRAY_OFFSET (type)))
     gfc_add_modify (&init, GFC_TYPE_ARRAY_OFFSET (type), offset);
 
   gfc_trans_vla_type_sizes (sym, &init);
@@ -8977,7 +8978,7 @@ gfc_alloc_allocatable_for_assignment (gf
   tmp = gfc_conv_descriptor_offset (desc);
   gfc_add_modify (&fblock, tmp, offset);
   if (linfo->saved_offset
-      && TREE_CODE (linfo->saved_offset) == VAR_DECL)
+      && VAR_P (linfo->saved_offset))
     gfc_add_modify (&fblock, linfo->saved_offset, tmp);
 
   /* Now set the deltas for the lhs.  */
@@ -8988,8 +8989,7 @@ gfc_alloc_allocatable_for_assignment (gf
       tmp = fold_build2_loc (input_location, MINUS_EXPR,
 			     gfc_array_index_type, tmp,
 			     loop->from[dim]);
-      if (linfo->delta[dim]
-	  && TREE_CODE (linfo->delta[dim]) == VAR_DECL)
+      if (linfo->delta[dim] && VAR_P (linfo->delta[dim]))
 	gfc_add_modify (&fblock, linfo->delta[dim], tmp);
     }
 
@@ -8998,7 +8998,7 @@ gfc_alloc_allocatable_for_assignment (gf
     {
       if (expr2->ts.deferred)
 	{
-	  if (TREE_CODE (expr2->ts.u.cl->backend_decl) == VAR_DECL)
+	  if (VAR_P (expr2->ts.u.cl->backend_decl))
 	    tmp = expr2->ts.u.cl->backend_decl;
 	  else
 	    tmp = rss->info->string_length;
@@ -9016,7 +9016,7 @@ gfc_alloc_allocatable_for_assignment (gf
 	}
 
       if (expr1->ts.u.cl->backend_decl
-	  && TREE_CODE (expr1->ts.u.cl->backend_decl) == VAR_DECL)
+	  && VAR_P (expr1->ts.u.cl->backend_decl))
 	gfc_add_modify (&fblock, expr1->ts.u.cl->backend_decl, tmp);
       else
 	gfc_add_modify (&fblock, lss->info->string_length, tmp);
@@ -9182,8 +9182,7 @@ gfc_alloc_allocatable_for_assignment (gf
   gfc_add_expr_to_block (&fblock, tmp);
 
   /* Make sure that the scalarizer data pointer is updated.  */
-  if (linfo->data
-      && TREE_CODE (linfo->data) == VAR_DECL)
+  if (linfo->data && VAR_P (linfo->data))
     {
       tmp = gfc_conv_descriptor_data_get (desc);
       gfc_add_modify (&fblock, linfo->data, tmp);
@@ -9227,8 +9226,8 @@ gfc_trans_deferred_array (gfc_symbol * s
   gfc_set_backend_locus (&sym->declared_at);
   gfc_init_block (&init);
 
-  gcc_assert (TREE_CODE (sym->backend_decl) == VAR_DECL
-		|| TREE_CODE (sym->backend_decl) == PARM_DECL);
+  gcc_assert (VAR_P (sym->backend_decl)
+	      || TREE_CODE (sym->backend_decl) == PARM_DECL);
 
   if (sym->ts.type == BT_CHARACTER
       && !INTEGER_CST_P (sym->ts.u.cl->backend_decl))
--- gcc/fortran/trans.c.jj	2016-10-24 10:26:03.610752683 +0200
+++ gcc/fortran/trans.c	2016-10-24 14:15:47.352075544 +0200
@@ -335,7 +335,7 @@ gfc_build_array_ref (tree base, tree off
      references.  */
   if (type && TREE_CODE (type) == ARRAY_TYPE
       && TYPE_MAXVAL (TYPE_DOMAIN (type)) != NULL_TREE
-      && (TREE_CODE (TYPE_MAXVAL (TYPE_DOMAIN (type))) == VAR_DECL
+      && (VAR_P (TYPE_MAXVAL (TYPE_DOMAIN (type)))
 	  || TREE_CODE (TYPE_MAXVAL (TYPE_DOMAIN (type))) == INDIRECT_REF)
       && decl
       && (TREE_CODE (TYPE_MAXVAL (TYPE_DOMAIN (type))) == INDIRECT_REF
@@ -356,9 +356,8 @@ gfc_build_array_ref (tree base, tree off
      subreference, use the span that is stored with the backend decl
      and reference the element with pointer arithmetic.  */
   if ((decl && (TREE_CODE (decl) == FIELD_DECL
-		|| TREE_CODE (decl) == VAR_DECL
-		|| TREE_CODE (decl) == PARM_DECL
-		|| TREE_CODE (decl) == FUNCTION_DECL)
+		|| VAR_OR_FUNCTION_DECL_P (decl)
+		|| TREE_CODE (decl) == PARM_DECL)
        && ((GFC_DECL_SUBREF_ARRAY_P (decl)
 	    && !integer_zerop (GFC_DECL_SPAN (decl)))
 	   || GFC_DECL_CLASS (decl)

	Jakub



More information about the Fortran mailing list