aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/decl.c15
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist118.C25
4 files changed, 39 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1552b3e..b047dbf 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2019-12-19 Marek Polacek <polacek@redhat.com>
+ PR c++/92745 - bogus error when initializing array of vectors.
+ * decl.c (reshape_init_r): For a nested compound literal, do
+ call reshape_init_{class,array,vector}.
+
PR c++/92974 - bogus location for enum and non-enum in ?: warning.
* tree.c (build_min_non_dep): Use the location of NON_DEP when
building the expression.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 7d4c947..c15cbfa 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6399,14 +6399,13 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p,
by the front end. Here we have e.g. {.__pfn=0B, .__delta=0},
which is missing outermost braces. We should warn below, and
one of the routines below will wrap it in additional { }. */;
- /* For a nested compound literal, there is no need to reshape since
- we called reshape_init in finish_compound_literal, before calling
- digest_init. */
- else if (COMPOUND_LITERAL_P (stripped_init)
- /* Similarly, a CONSTRUCTOR of the target's type is a
- previously digested initializer. */
- || same_type_ignoring_top_level_qualifiers_p (type,
- init_type))
+ /* For a nested compound literal, proceed to specialized routines,
+ to handle initialization of arrays and similar. */
+ else if (COMPOUND_LITERAL_P (stripped_init))
+ gcc_assert (!BRACE_ENCLOSED_INITIALIZER_P (stripped_init));
+ /* A CONSTRUCTOR of the target's type is a previously
+ digested initializer. */
+ else if (same_type_ignoring_top_level_qualifiers_p (type, init_type))
{
++d->cur;
gcc_assert (!BRACE_ENCLOSED_INITIALIZER_P (stripped_init));
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a7835db..207d64a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2019-12-19 Marek Polacek <polacek@redhat.com>
+ PR c++/92745 - bogus error when initializing array of vectors.
+ * g++.dg/cpp0x/initlist118.C: New test.
+
PR c++/92974 - bogus location for enum and non-enum in ?: warning.
* g++.dg/diagnostic/enum1.C: New test.
* g++.dg/gomp/loop-2.C: Adjust dg-error.
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist118.C b/gcc/testsuite/g++.dg/cpp0x/initlist118.C
new file mode 100644
index 0000000..2e1b969
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist118.C
@@ -0,0 +1,25 @@
+// PR c++/92745 - bogus error when initializing array of vectors.
+// { dg-do compile { target c++11 } }
+
+template <typename a, int b> struct c {
+ typedef a d[b];
+};
+
+template <typename a, int b> struct array {
+ typename c<a, b>::d e;
+ a operator[](long);
+};
+
+template<class T>
+using vec4_t __attribute__((vector_size(4*sizeof(T)))) = float;
+
+array<vec4_t<float>, 4>
+transpose(array<vec4_t<float>, 4> col)
+{
+ array<vec4_t<float>, 4>
+ ret{vec4_t<float>{col[0][0], col[1][0], col[2][0], col[3][0]},
+ vec4_t<float>{col[0][1], col[1][1], col[2][1], col[3][1]},
+ vec4_t<float>{col[0][2], col[1][2], col[2][2], col[3][2]},
+ vec4_t<float>{col[0][3], col[1][3], col[2][3], col[3][3]}};
+ return ret;
+}