[PATCH] rust: Convert build_int_cst (NULL_TREE, cst). [PR126622]

Kael Andrew Franco kaelfandrew@gmail.com
Mon Sep 7 18:16:40 GMT 2026


https://gcc.gnu.org/pipermail/gcc-patches/2026-September/730258.html
did not work on ARM bootstrap. Please ignore this patch.


On Mon, Sep 7, 2026 at 9:56 AM Kael Andrew Alonzo Franco
<kaelfandrew@gmail.com> wrote:
>
> build_int_cst converts NULL_TREE to integer_type_node.
> Use build_int_cst (integer_type_node, cst) to prepare a patch
> to remove build_int_cst_type.
>
> Bootstrapped and regtested on x86_64-pc-linux-gnu.
>
>         PR middle-end/126622
>
> gcc/rust/ChangeLog:
>
>         * backend/rust-builtins.cc (DEF_ATTR_INT): Use
>         build_int_cst (integer_type_node, cst).
>         * backend/rust-constexpr.cc (eval_bit_field_ref):
>         Use build_int_cst.
>
> Signed-off-by: Kael Andrew Franco <kaelfandrew@gmail.com>
> ---
>  gcc/rust/backend/rust-builtins.cc  | 2 +-
>  gcc/rust/backend/rust-constexpr.cc | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/rust/backend/rust-builtins.cc b/gcc/rust/backend/rust-builtins.cc
> index 881561fdde3..d4b072a03e7 100644
> --- a/gcc/rust/backend/rust-builtins.cc
> +++ b/gcc/rust/backend/rust-builtins.cc
> @@ -228,7 +228,7 @@ BuiltinsContext::define_builtin_attributes ()
>
>  #define DEF_ATTR_NULL_TREE(ENUM) built_in_attributes[(int) ENUM] = NULL_TREE;
>  #define DEF_ATTR_INT(ENUM, VALUE)                                              \
> -  built_in_attributes[ENUM] = build_int_cst (NULL_TREE, VALUE);
> +  built_in_attributes[ENUM] = build_int_cst (integer_type_node, VALUE);
>  #define DEF_ATTR_STRING(ENUM, VALUE)                                           \
>    built_in_attributes[ENUM] = build_string (strlen (VALUE), VALUE);
>  #define DEF_ATTR_IDENT(ENUM, STRING)                                           \
> diff --git a/gcc/rust/backend/rust-constexpr.cc b/gcc/rust/backend/rust-constexpr.cc
> index e32ba3abd4f..5a7e7a711c3 100644
> --- a/gcc/rust/backend/rust-constexpr.cc
> +++ b/gcc/rust/backend/rust-constexpr.cc
> @@ -4994,7 +4994,7 @@ eval_bit_field_ref (const constexpr_ctx *ctx, tree t, bool lval,
>           if (bit >= istart && bit + sz <= istart + isize)
>             {
>               fldval = fold_convert (utype, value);
> -             mask = build_int_cst_type (utype, -1);
> +             mask = build_int_cst (utype, -1);
>               mask = fold_build2 (LSHIFT_EXPR, utype, mask,
>                                   size_int (TYPE_PRECISION (utype) - sz));
>               mask = fold_build2 (RSHIFT_EXPR, utype, mask,
> --
> 2.55.0
>


More information about the Gcc-rust mailing list