]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
s390: Fix builtin s390_vec_load_bndry for C++
authorStefan Schulze Frielinghaus <stefansf@gcc.gnu.org>
Fri, 12 Dec 2025 19:44:45 +0000 (20:44 +0100)
committerStefan Schulze Frielinghaus <stefansf@gcc.gnu.org>
Fri, 12 Dec 2025 19:44:45 +0000 (20:44 +0100)
The second argument for builtin s390_vec_load_bndry must be an integer
constant.  The C++ front end wraps a constant inside a NON_LVALUE_EXPR
which we need to unpack first.  Otherwise we bail out in
s390_adjust_builtin_arglist():

t.C: In function ‘__vector(4) unsigned int test(const unsigned int*)’:
t.C:7:42: error: constant value required for builtin ‘__vector(16) signed char __builtin_s390_vlbb(const void*, int)’ argument 2
    7 |     return __builtin_s390_vec_load_bndry (x, 4096);
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~

gcc/ChangeLog:

* config/s390/s390-c.cc (s390_adjust_builtin_arglist): Fix
builtin s390_vec_load_bndry for C++.

gcc/config/s390/s390-c.cc

index 001bb2f4a0a45fa20582739c20544f8dcc1d53d3..041ca870f1ad966e81e380e814db93f3c0ea6e18 100644 (file)
@@ -736,6 +736,9 @@ s390_adjust_builtin_arglist (unsigned int ob_fcode, tree decl,
              {
                tree arg = (**arglist)[src_arg_index];
 
+               if (c_dialect_cxx () && TREE_CODE (arg) == NON_LVALUE_EXPR)
+                 arg = TREE_OPERAND (arg, 0);
+
                if (TREE_CODE (arg) != INTEGER_CST)
                  {
                    error ("constant value required for builtin %qF argument %d",
@@ -758,8 +761,11 @@ s390_adjust_builtin_arglist (unsigned int ob_fcode, tree decl,
                           src_arg_index + 1);
                    return;
                  }
-               folded_args->quick_push (build_int_cst (integer_type_node,
-                                                       code));
+
+               arg = build_int_cst (integer_type_node, code);
+               if (c_dialect_cxx ())
+                 arg = build1 (NON_LVALUE_EXPR, integer_type_node, arg);
+               folded_args->quick_push (arg);
                src_arg_index++;
                arg_assigned_p = true;
              }