https://gcc.gnu.org/g:0cd3647c9e7946c64524cea247514fd7d282e60c

commit r16-6067-g0cd3647c9e7946c64524cea247514fd7d282e60c
Author: Stefan Schulze Frielinghaus <[email protected]>
Date:   Fri Dec 12 20:44:45 2025 +0100

    s390: Fix builtin s390_vec_load_bndry for C++
    
    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++.

Diff:
---
 gcc/config/s390/s390-c.cc | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/s390/s390-c.cc b/gcc/config/s390/s390-c.cc
index 001bb2f4a0a4..041ca870f1ad 100644
--- a/gcc/config/s390/s390-c.cc
+++ b/gcc/config/s390/s390-c.cc
@@ -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;
              }

Reply via email to