From c4210852f1e7f5aa901411a3f82059d54d2287c8 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 22 Feb 2018 22:50:37 +0000 Subject: [PATCH] PR c++/84424 - ICE with constexpr and __builtin_shuffle. * constexpr.c (reduced_constant_expression_p): Handle CONSTRUCTOR of VECTOR_TYPE. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257924 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/constexpr.c | 8 +++++++- gcc/testsuite/g++.dg/ext/vector34.C | 8 ++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ext/vector34.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f38f662f8f5..79b7f00644d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-02-22 Jason Merrill + + PR c++/84424 - ICE with constexpr and __builtin_shuffle. + * constexpr.c (reduced_constant_expression_p): Handle CONSTRUCTOR of + VECTOR_TYPE. + 2018-02-22 Marek Polacek PR c++/84493 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index f095b038d32..47ff90cb055 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -1763,7 +1763,13 @@ reduced_constant_expression_p (tree t) /* And we need to handle PTRMEM_CST wrapped in a CONSTRUCTOR. */ tree idx, val, field; unsigned HOST_WIDE_INT i; if (CONSTRUCTOR_NO_IMPLICIT_ZERO (t)) - field = next_initializable_field (TYPE_FIELDS (TREE_TYPE (t))); + { + if (TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE) + /* An initialized vector would have a VECTOR_CST. */ + return false; + else + field = next_initializable_field (TYPE_FIELDS (TREE_TYPE (t))); + } else field = NULL_TREE; FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t), i, idx, val) diff --git a/gcc/testsuite/g++.dg/ext/vector34.C b/gcc/testsuite/g++.dg/ext/vector34.C new file mode 100644 index 00000000000..5cca53070b2 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vector34.C @@ -0,0 +1,8 @@ +// PR c++/84424 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +typedef int vec __attribute__ ((vector_size (2 * sizeof (int)))); + +constexpr vec u = { 1, 2 }; +constexpr vec v = __builtin_shuffle (v, u); // { dg-error "" } -- 2.11.4.GIT