+2020-02-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/93549
+ * constexpr.c (find_array_ctor_elt): If last element has no index,
+ for flag_checking verify all elts have no index. If i is within the
+ elts, return it directly, if it is right after the last elt, append
+ if NULL index, otherwise force indexes on all elts.
+ (cxx_eval_store_expression): Allow cep->index to be NULL.
+
2020-02-07 Marek Polacek <polacek@redhat.com>
PR c++/92947 - Paren init of aggregates in unevaluated context.
if (end > 0)
{
tree cindex = (*elts)[end - 1].index;
- if (TREE_CODE (cindex) == INTEGER_CST
- && compare_tree_int (cindex, end - 1) == 0)
+ if (cindex == NULL_TREE)
+ {
+ /* Verify that if the last index is missing, all indexes
+ are missing. */
+ if (flag_checking)
+ for (unsigned int j = 0; j < len - 1; ++j)
+ gcc_assert ((*elts)[j].index == NULL_TREE);
+ if (i < end)
+ return i;
+ else
+ {
+ begin = end;
+ if (i == end)
+ /* If the element is to be added right at the end,
+ make sure it is added with cleared index too. */
+ dindex = NULL_TREE;
+ else if (insert)
+ /* Otherwise, in order not to break the assumption
+ that CONSTRUCTOR either has all indexes or none,
+ we need to add indexes to all elements. */
+ for (unsigned int j = 0; j < len; ++j)
+ (*elts)[j].index = build_int_cst (TREE_TYPE (dindex), j);
+ }
+ }
+ else if (TREE_CODE (cindex) == INTEGER_CST
+ && compare_tree_int (cindex, end - 1) == 0)
{
if (i < end)
return i;
= find_array_ctor_elt (*valp, index, /*insert*/true);
gcc_assert (i >= 0);
cep = CONSTRUCTOR_ELT (*valp, i);
- gcc_assert (TREE_CODE (cep->index) != RANGE_EXPR);
+ gcc_assert (cep->index == NULL_TREE
+ || TREE_CODE (cep->index) != RANGE_EXPR);
}
else
{
+2020-02-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/93549
+ * g++.dg/ext/constexpr-pr93549.C: New test.
+
2020-02-08 Uroš Bizjak <ubizjak@gmail.com>
Jakub Jelinek <jakub@redhat.com>
--- /dev/null
+// PR c++/93549
+// { dg-do compile { target c++17 } }
+// { dg-options "-O2 -Wno-psabi -w" }
+
+struct simd {
+ using shortx8 [[gnu::vector_size(16)]] = short;
+ shortx8 data;
+ constexpr simd (short x) : data{x, x, x, x, x, x, x, x} {}
+ constexpr friend unsigned operator== (simd lhs, simd rhs)
+ {
+ shortx8 tmp = lhs.data == rhs.data;
+ using ushort = unsigned short;
+ auto bools = tmp ? ushort(1) : ushort(0);
+ unsigned bits = 0;
+ for (int i = 0; i < 8; ++i)
+ bits |= bools[i] << i;
+ return bits;
+ }
+};
+
+auto
+foo ()
+{
+ constexpr auto tmp = simd(1) == simd(2);
+ return tmp;
+}