Hi,
On 22/03/2018 23:26, Jason Merrill wrote:
On Thu, Mar 22, 2018 at 5:39 PM, Paolo Carlini <paolo.carl...@oracle.com> wrote:
... with patch ;)
If you are curious where the heck that INDIRECT_REF is coming from, is
coming from the gimplifier, cp_gimpliify_expr, via build_vec_init. Grrr.
Hmm, maybe build_vec_init should call itself directly rather than via
build_aggr_init in the case of multidimensional arrays.
Yes, arranging things like that seems doable. However, yesterday, while
fiddling with the idea and instrumenting the code with some gcc_asserts,
I noticed that we have yet another tree code to handle, TARGET_EXPR, as
in lines #41, #47, #56 of ext/complit12.C, and in that case
build_aggr_init is simply called by check_initializer via
build_aggr_init_full_exprs, the "normal" path. Well, unless we want to
adjust/reject complit12.C too, which clang rejects, in fact with errors
on lines #19 and #29 too. The below passes testing.
Thanks,
Paolo.
/////////////////
Index: cp/init.c
===================================================================
--- cp/init.c (revision 258758)
+++ cp/init.c (working copy)
@@ -1688,14 +1688,6 @@ build_aggr_init (tree exp, tree init, int flags, t
}
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,16 @@ build_aggr_init (tree exp, tree init, int flags, t
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
+ && TREE_CODE (init) != INDIRECT_REF
+ && 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;
}
}
Index: testsuite/g++.dg/init/array49.C
===================================================================
--- testsuite/g++.dg/init/array49.C (nonexistent)
+++ testsuite/g++.dg/init/array49.C (working copy)
@@ -0,0 +1,6 @@
+// PR c++/84632
+// { dg-additional-options "-w" }
+
+class {
+ &a; // { dg-error "forbids declaration" }
+} b[2] = b; // { dg-error "initialized" }
Index: testsuite/g++.dg/torture/pr70499.C
===================================================================
--- testsuite/g++.dg/torture/pr70499.C (revision 258758)
+++ testsuite/g++.dg/torture/pr70499.C (working copy)
@@ -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 () {