aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2018-03-27 06:52:04 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2018-03-27 06:52:04 +0000
commite278212eeea4f57d8478bf5c6be05fd7bdb2dc8e (patch)
tree62c90d8b8bc9300030a7e3c47be7ffb35d7c1441 /gcc
parent74d2d97382ddfec2fd51c6a90950cf29c3ba9fd5 (diff)
downloadgcc-e278212eeea4f57d8478bf5c6be05fd7bdb2dc8e.zip
gcc-e278212eeea4f57d8478bf5c6be05fd7bdb2dc8e.tar.gz
gcc-e278212eeea4f57d8478bf5c6be05fd7bdb2dc8e.tar.bz2
re PR c++/84632 (internal compiler error: tree check: expected record_type or union_type or qual_union_type, have array_type in reduced_constant_expression_p, at cp/constexpr.c:1778)
/cp 2018-03-27 Paolo Carlini <paolo.carlini@oracle.com> Jason Merrill <jason@redhat.com> PR c++/84632 * init.c (build_aggr_init): When initializing from array, reject anything but CONSTRUCTORs and TARGET_EXPRs. (build_vec_init): Handle separately ARRAY_TYPEs. /testsuite 2018-03-27 Paolo Carlini <paolo.carlini@oracle.com> Jason Merrill <jason@redhat.com> PR c++/84632 * g++.dg/init/array49.C: New. * g++.dg/torture/pr70499.C: Adjust. Co-Authored-By: Jason Merrill <jason@redhat.com> From-SVN: r258870
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/init.c28
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/g++.dg/init/array49.C6
-rw-r--r--gcc/testsuite/g++.dg/torture/pr70499.C4
5 files changed, 36 insertions, 17 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 34d5101..654e608 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2018-03-27 Paolo Carlini <paolo.carlini@oracle.com>
+ Jason Merrill <jason@redhat.com>
+
+ PR c++/84632
+ * init.c (build_aggr_init): When initializing from array,
+ reject anything but CONSTRUCTORs and TARGET_EXPRs.
+ (build_vec_init): Handle separately ARRAY_TYPEs.
+
2018-03-26 Jason Merrill <jason@redhat.com>
PR c++/85062 - ICE with alignas in wrong place.
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index ff52c42..e52cd64 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1688,14 +1688,6 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain)
}
else
{
- /* An array may not be initialized use the parenthesized
- initialization form -- unless the initializer is "()". */
- if (init && TREE_CODE (init) == TREE_LIST)
- {
- if (complain & tf_error)
- error ("bad array initializer");
- return error_mark_node;
- }
/* Must arrange to initialize each element of EXP
from elements of INIT. */
if (cv_qualified_p (type))
@@ -1705,14 +1697,17 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain)
from_array = (itype && same_type_p (TREE_TYPE (init),
TREE_TYPE (exp)));
- if (init && !from_array
- && !BRACE_ENCLOSED_INITIALIZER_P (init))
+ if (init && !BRACE_ENCLOSED_INITIALIZER_P (init)
+ && (!from_array
+ || (TREE_CODE (init) != CONSTRUCTOR
+ /* Can happen, eg, handling the compound-literals
+ extension (ext/complit12.C). */
+ && TREE_CODE (init) != TARGET_EXPR)))
{
if (complain & tf_error)
- permerror (init_loc, "array must be initialized "
- "with a brace-enclosed initializer");
- else
- return error_mark_node;
+ error_at (init_loc, "array must be initialized "
+ "with a brace-enclosed initializer");
+ return error_mark_node;
}
}
@@ -4367,7 +4362,10 @@ build_vec_init (tree base, tree maxindex, tree init,
else
from = NULL_TREE;
- if (from_array == 2)
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ elt_init = build_vec_init (to, NULL_TREE, from, /*val_init*/false,
+ from_array, complain);
+ else if (from_array == 2)
elt_init = cp_build_modify_expr (input_location, to, NOP_EXPR,
from, complain);
else if (type_build_ctor_call (type))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 857870a..87d9bd4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2018-03-27 Paolo Carlini <paolo.carlini@oracle.com>
+ Jason Merrill <jason@redhat.com>
+
+ PR c++/84632
+ * g++.dg/init/array49.C: New.
+ * g++.dg/torture/pr70499.C: Adjust.
+
2018-03-26 Uros Bizjak <ubizjak@gmail.com>
PR target/85073
diff --git a/gcc/testsuite/g++.dg/init/array49.C b/gcc/testsuite/g++.dg/init/array49.C
new file mode 100644
index 0000000..9905483
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/array49.C
@@ -0,0 +1,6 @@
+// PR c++/84632
+// { dg-additional-options "-w" }
+
+class {
+ &a; // { dg-error "forbids declaration" }
+} b[2] = b; // { dg-error "initialized" }
diff --git a/gcc/testsuite/g++.dg/torture/pr70499.C b/gcc/testsuite/g++.dg/torture/pr70499.C
index e08c26f..4b8b332 100644
--- a/gcc/testsuite/g++.dg/torture/pr70499.C
+++ b/gcc/testsuite/g++.dg/torture/pr70499.C
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-additional-options "-w -fpermissive -Wno-psabi" }
+// { dg-additional-options "-w -Wno-psabi" }
// { dg-additional-options "-mavx" { target x86_64-*-* i?86-*-* } }
typedef double __m256d __attribute__ ((__vector_size__ (32), __may_alias__));
@@ -30,7 +30,7 @@ struct Foo {
template<typename Tx>
__attribute__((__always_inline__)) inline void inlineFunc(Tx hx[]) {
Tx x = hx[0], y = hx[1];
- Tx lam[1] = (x*y);
+ Tx lam[1] = {(x*y)};
}
void FooBarFunc () {