From: Paolo Carlini Date: Tue, 27 Mar 2018 06:52:04 +0000 (+0000) Subject: re PR c++/84632 (internal compiler error: tree check: expected record_type or union_t... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e278212eeea4f57d8478bf5c6be05fd7bdb2dc8e;p=gcc.git 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 Jason Merrill 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 Jason Merrill PR c++/84632 * g++.dg/init/array49.C: New. * g++.dg/torture/pr70499.C: Adjust. Co-Authored-By: Jason Merrill From-SVN: r258870 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 34d5101963d..654e608c6b5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2018-03-27 Paolo Carlini + Jason Merrill + + 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 PR c++/85062 - ICE with alignas in wrong place. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index ff52c42c1ad..e52cd64acc8 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 857870af870..87d9bd4b204 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-03-27 Paolo Carlini + Jason Merrill + + PR c++/84632 + * g++.dg/init/array49.C: New. + * g++.dg/torture/pr70499.C: Adjust. + 2018-03-26 Uros Bizjak 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 00000000000..9905483f738 --- /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 e08c26f5674..4b8b3329d6c 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 __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 () {