diff mbox series

[09/14] rust: use _P() defines from tree.h

Message ID 20230513232321.279733-10-rep.dot.nop@gmail.com
State New
Headers show
Series use _P() defines from tree.h | expand

Commit Message

Bernhard Reutner-Fischer May 13, 2023, 11:23 p.m. UTC
From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>

gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::type_cast_expression): Use
	_P() defines from tree.h
	* backend/rust-tree.cc (build_cplus_array_type): Ditto.
	* backend/rust-tree.h (ARITHMETIC_TYPE_P): Ditto.
	(gnu_vector_type_p): Ditto.
	* checks/lints/rust-lint-unused-var.cc (check_decl): Ditto.
	* rust-gcc.cc (Gcc_backend::fill_in_array): Ditto.
	(Gcc_backend::named_type): Ditto.
	(Gcc_backend::convert_expression): Ditto.
	(Gcc_backend::init_statement): Ditto.
---
 gcc/rust/backend/rust-compile-expr.cc         | 2 +-
 gcc/rust/backend/rust-tree.cc                 | 2 +-
 gcc/rust/backend/rust-tree.h                  | 4 ++--
 gcc/rust/checks/lints/rust-lint-unused-var.cc | 2 +-
 gcc/rust/rust-gcc.cc                          | 8 ++++----
 5 files changed, 9 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc
index d7945dbf26b..3dc34828e32 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -2267,7 +2267,7 @@  CompileExpr::type_cast_expression (tree type_to_cast_to, tree expr_tree,
       // FIXME check for TREE_OVERFLOW?
       return cast;
     }
-  else if (TREE_CODE (type_to_cast_to) == REAL_TYPE)
+  else if (SCALAR_FLOAT_TYPE_P (type_to_cast_to))
     {
       tree cast = convert_to_real (type_to_cast_to, expr_tree);
       // FIXME
diff --git a/gcc/rust/backend/rust-tree.cc b/gcc/rust/backend/rust-tree.cc
index 8243d4cf5c6..7e11e6584ae 100644
--- a/gcc/rust/backend/rust-tree.cc
+++ b/gcc/rust/backend/rust-tree.cc
@@ -2404,7 +2404,7 @@  build_cplus_array_type (tree elt_type, tree index_type, int dependent)
     }
 
   /* Avoid spurious warnings with VLAs (c++/54583).  */
-  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
+  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))
     suppress_warning (TYPE_SIZE (t), OPT_Wunused);
 
   /* Push these needs up to the ARRAY_TYPE so that initialization takes
diff --git a/gcc/rust/backend/rust-tree.h b/gcc/rust/backend/rust-tree.h
index 284fd873c1c..6d243b7f86e 100644
--- a/gcc/rust/backend/rust-tree.h
+++ b/gcc/rust/backend/rust-tree.h
@@ -54,7 +54,7 @@ 
 
    Keep these checks in ascending code order.  */
 #define ARITHMETIC_TYPE_P(TYPE)                                                \
-  (RS_INTEGRAL_TYPE_P (TYPE) || TREE_CODE (TYPE) == REAL_TYPE                  \
+  (RS_INTEGRAL_TYPE_P (TYPE) || SCALAR_FLOAT_TYPE_P (TYPE)		  \
    || TREE_CODE (TYPE) == COMPLEX_TYPE)
 
 /* True iff TYPE is cv decltype(nullptr).  */
@@ -3250,7 +3250,7 @@  identifier_p (tree t)
 inline bool
 gnu_vector_type_p (const_tree type)
 {
-  return TREE_CODE (type) == VECTOR_TYPE && !TYPE_INDIVISIBLE_P (type);
+  return VECTOR_TYPE_P (type) && !TYPE_INDIVISIBLE_P (type);
 }
 
 extern vec<tree, va_gc> *
diff --git a/gcc/rust/checks/lints/rust-lint-unused-var.cc b/gcc/rust/checks/lints/rust-lint-unused-var.cc
index ba5ffb9372b..2cf5cd60f15 100644
--- a/gcc/rust/checks/lints/rust-lint-unused-var.cc
+++ b/gcc/rust/checks/lints/rust-lint-unused-var.cc
@@ -25,7 +25,7 @@  namespace Analysis {
 static void
 check_decl (tree *t)
 {
-  rust_assert (TREE_CODE (*t) == VAR_DECL || TREE_CODE (*t) == PARM_DECL
+  rust_assert (VAR_P (*t) || TREE_CODE (*t) == PARM_DECL
 	       || TREE_CODE (*t) == CONST_DECL);
 
   tree var_name = DECL_NAME (*t);
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index cf20b5b98e0..b1995bdb56a 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -886,7 +886,7 @@  Gcc_backend::fill_in_array (tree fill, tree element_type, tree length_tree)
   if (element_type == error_mark_node || length_tree == error_mark_node)
     return error_mark_node;
 
-  gcc_assert (TYPE_SIZE (element_type) != NULL_TREE);
+  gcc_assert (COMPLETE_TYPE_P (element_type));
 
   length_tree = fold_convert (sizetype, length_tree);
 
@@ -923,7 +923,7 @@  Gcc_backend::named_type (const std::string &name, tree type, Location location)
   // give it whatever Rust name we have at this point.
   if (TYPE_NAME (type) == NULL_TREE
       && location.gcc_location () == BUILTINS_LOCATION
-      && (TREE_CODE (type) == INTEGER_TYPE || TREE_CODE (type) == REAL_TYPE
+      && (TREE_CODE (type) == INTEGER_TYPE || SCALAR_FLOAT_TYPE_P (type)
 	  || TREE_CODE (type) == COMPLEX_TYPE
 	  || TREE_CODE (type) == BOOLEAN_TYPE))
     {
@@ -1173,7 +1173,7 @@  Gcc_backend::convert_expression (tree type_tree, tree expr_tree,
     }
   else if (TREE_CODE (type_tree) == INTEGER_TYPE)
     ret = convert_to_integer (type_tree, expr_tree);
-  else if (TREE_CODE (type_tree) == REAL_TYPE)
+  else if (SCALAR_FLOAT_TYPE_P (type_tree))
     ret = convert_to_real (type_tree, expr_tree);
   else if (TREE_CODE (type_tree) == COMPLEX_TYPE)
     ret = convert_to_complex (type_tree, expr_tree);
@@ -1935,7 +1935,7 @@  Gcc_backend::init_statement (tree, Bvariable *var, tree init_tree)
   tree var_tree = var->get_decl ();
   if (var_tree == error_mark_node || init_tree == error_mark_node)
     return error_mark_node;
-  gcc_assert (TREE_CODE (var_tree) == VAR_DECL);
+  gcc_assert (VAR_P (var_tree));
 
   // To avoid problems with GNU ld, we don't make zero-sized
   // externally visible variables.  That might lead us to doing an