]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc/: Merge definitions of array_type_nelts_top
authorAlejandro Colomar <alx@kernel.org>
Wed, 16 Oct 2024 12:10:48 +0000 (14:10 +0200)
committerJoseph Myers <josmyers@redhat.com>
Fri, 18 Oct 2024 22:42:16 +0000 (22:42 +0000)
There were two identical definitions, and none of them are available
where they are needed for implementing a number-of-elements-of
operator.  Merge them, and provide the single definition in
gcc/tree.{h,cc}, where it's available for that operator, which will be
added in a following commit.

gcc/ChangeLog:

* tree.h (array_type_nelts_top)
* tree.cc (array_type_nelts_top):
Define function (moved from gcc/cp/).

gcc/cp/ChangeLog:

* cp-tree.h (array_type_nelts_top)
* tree.cc (array_type_nelts_top):
Remove function (move to gcc/).

gcc/rust/ChangeLog:

* backend/rust-tree.h (array_type_nelts_top)
* backend/rust-tree.cc (array_type_nelts_top):
Remove function.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
gcc/cp/cp-tree.h
gcc/cp/tree.cc
gcc/rust/backend/rust-tree.cc
gcc/rust/backend/rust-tree.h
gcc/tree.cc
gcc/tree.h

index 94ee550bd9cbcc3332a5205484101469a91c6c45..a44100a2bc436169a6f6614725a7fd134bf6e670 100644 (file)
@@ -8121,7 +8121,6 @@ extern tree build_exception_variant               (tree, tree);
 extern void fixup_deferred_exception_variants   (tree, tree);
 extern tree bind_template_template_parm                (tree, tree);
 extern tree array_type_nelts_total             (tree);
-extern tree array_type_nelts_top               (tree);
 extern bool array_of_unknown_bound_p           (const_tree);
 extern tree break_out_target_exprs             (tree, bool = false);
 extern tree build_ctor_subob_ref               (tree, tree, tree);
index 3cac8ac4df1b6bb159324c887a612fbd6a065784..c80ee0689588fd2c59c796eaea021997b76ea16e 100644 (file)
@@ -3076,19 +3076,6 @@ cxx_print_statistics (void)
             depth_reached);
 }
 
-/* Return, as an INTEGER_CST node, the number of elements for TYPE
-   (which is an ARRAY_TYPE).  This counts only elements of the top
-   array.  */
-
-tree
-array_type_nelts_top (tree type)
-{
-  return fold_build2_loc (input_location,
-                     PLUS_EXPR, sizetype,
-                     array_type_nelts_minus_one (type),
-                     size_one_node);
-}
-
 /* Return, as an INTEGER_CST node, the number of elements for TYPE
    (which is an ARRAY_TYPE).  This one is a recursive count of all
    ARRAY_TYPEs that are clumped together.  */
index 8d32e5203aea014666b4ffa2662b1e1653ac392d..3dc6b076711220f670e0ed15a368367f739405e3 100644 (file)
@@ -859,19 +859,6 @@ is_empty_class (tree type)
   return CLASSTYPE_EMPTY_P (type);
 }
 
-// forked from gcc/cp/tree.cc array_type_nelts_top
-
-/* Return, as an INTEGER_CST node, the number of elements for TYPE
-   (which is an ARRAY_TYPE).  This counts only elements of the top
-   array.  */
-
-tree
-array_type_nelts_top (tree type)
-{
-  return fold_build2_loc (input_location, PLUS_EXPR, sizetype,
-                         array_type_nelts_minus_one (type), size_one_node);
-}
-
 // forked from gcc/cp/tree.cc builtin_valid_in_constant_expr_p
 
 /* Test whether DECL is a builtin that may appear in a
index 26c8b653ac64dd36b12e68411e31e5b36d18ebb0..e597c3ab81d9abded17f6f6e759f2fac0d505799 100644 (file)
@@ -2993,8 +2993,6 @@ extern location_t rs_expr_location (const_tree);
 extern int
 is_empty_class (tree type);
 
-extern tree array_type_nelts_top (tree);
-
 extern bool
 is_really_empty_class (tree, bool);
 
index 94c6d086bd73a81e93897351791f526a30b9ce96..b40f4d31b2f19819fca1d7fc54db517bbc2b2f3b 100644 (file)
@@ -3732,6 +3732,19 @@ array_type_nelts_minus_one (const_tree type)
          ? max
          : fold_build2 (MINUS_EXPR, TREE_TYPE (max), max, min));
 }
+
+/* Return, as an INTEGER_CST node, the number of elements for TYPE
+   (which is an ARRAY_TYPE).  This counts only elements of the top
+   array.  */
+
+tree
+array_type_nelts_top (tree type)
+{
+  return fold_build2_loc (input_location,
+                     PLUS_EXPR, sizetype,
+                     array_type_nelts_minus_one (type),
+                     size_one_node);
+}
 \f
 /* If arg is static -- a reference to an object in static storage -- then
    return the object.  This is not the same as the C meaning of `static'.
index c996821c95340e53e8de4c573364ad24f53865b8..f4c89f5477c50cd3fdc3fbfdc7e0360c7da4363a 100644 (file)
@@ -4930,6 +4930,7 @@ extern tree build_method_type (tree, tree);
 extern tree build_offset_type (tree, tree);
 extern tree build_complex_type (tree, bool named = false);
 extern tree array_type_nelts_minus_one (const_tree);
+extern tree array_type_nelts_top (tree);
 
 extern tree value_member (tree, tree);
 extern tree purpose_member (const_tree, tree);