public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-8495] c++: Use fold_non_dependent_expr rather than maybe_constant_value in __builtin_shufflevector handlin
Date: Sun, 19 Jun 2022 10:09:02 +0000 (GMT)	[thread overview]
Message-ID: <20220619100902.98FBD3851A93@sourceware.org> (raw)

https://gcc.gnu.org/g:566e599c8194f789b077eb94a5e45ced2de5b31e

commit r12-8495-g566e599c8194f789b077eb94a5e45ced2de5b31e
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Jun 17 17:40:49 2022 +0200

    c++: Use fold_non_dependent_expr rather than maybe_constant_value in __builtin_shufflevector handling [PR106001]
    
    In this case the STATIC_CAST_EXPR expressions in the call aren't
    type nor value dependent, but maybe_constant_value still ICEs on those
    when processing_template_decl.  Calling fold_non_dependent_expr on it
    instead fixes the ICE and folds them to INTEGER_CSTs.
    
    2022-06-17  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/106001
            * typeck.cc (build_x_shufflevector): Use fold_non_dependent_expr
            instead of maybe_constant_value.
    
            * g++.dg/ext/builtin-shufflevector-4.C: New test.
    
    (cherry picked from commit a284fadcce8ef443cc3cc047a8017745efb51758)

Diff:
---
 gcc/cp/typeck.cc                                   |  2 +-
 gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index a6c393647b2..ceb80d9744f 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -6334,7 +6334,7 @@ build_x_shufflevector (location_t loc, vec<tree, va_gc> *args,
   auto_vec<tree, 16> mask;
   for (unsigned i = 2; i < args->length (); ++i)
     {
-      tree idx = maybe_constant_value ((*args)[i]);
+      tree idx = fold_non_dependent_expr ((*args)[i], complain);
       mask.safe_push (idx);
     }
   tree exp = c_build_shufflevector (loc, arg0, arg1, mask, complain & tf_error);
diff --git a/gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C b/gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C
new file mode 100644
index 00000000000..dae129b11d6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C
@@ -0,0 +1,18 @@
+// PR c++/106001
+// { dg-do compile }
+
+typedef int V __attribute__((vector_size (2 * sizeof (int))));
+
+template <int>
+void
+foo ()
+{
+  V v = {};
+  v = __builtin_shufflevector (v, v, static_cast<char>(1), static_cast<char>(0));
+}
+
+void
+bar ()
+{
+  foo <0> ();
+}


                 reply	other threads:[~2022-06-19 10:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220619100902.98FBD3851A93@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).