]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rust: Use FLOAT_TYPE_P instead of manual checking
authorAndrew Pinski <quic_apinski@quicinc.com>
Thu, 20 Mar 2025 00:29:59 +0000 (17:29 -0700)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 14 Apr 2025 16:23:51 +0000 (18:23 +0200)
This moves is_floating_point over to using FLOAT_TYPE_P instead
of manually checking. Note before it would return true for all
COMPLEX_TYPE but complex types' inner type could be integral.

Also fixes up the comment to be in more of the GNU style.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/rust/ChangeLog:

* rust-gcc.cc (is_floating_point): Use FLOAT_TYPE_P
instead of manually checking the type.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/rust/rust-gcc.cc

index 72aef08e35a0df9db2b6b89be7b9e31549416c06..7c5af211bbc773475faf5abe9ae43be5dc491352 100644 (file)
@@ -1021,12 +1021,12 @@ operator_to_tree_code (LazyBooleanOperator op)
     }
 }
 
-/* Helper function for deciding if a tree is a floating point node. */
+/* Returns true if the type of EXP is a floating point type.
+   False otherwise.  */
 bool
-is_floating_point (tree t)
+is_floating_point (tree exp)
 {
-  auto tree_type = TREE_CODE (TREE_TYPE (t));
-  return tree_type == REAL_TYPE || tree_type == COMPLEX_TYPE;
+  return FLOAT_TYPE_P (TREE_TYPE (exp));
 }
 
 // Return an expression for the negation operation OP EXPR.