From: Paolo Carlini <paolo.carlini@oracle.com>
To: Jason Merrill <jason@redhat.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [C++ Patch] PR 65815
Date: Mon, 08 Jun 2015 23:20:00 -0000 [thread overview]
Message-ID: <55761EB7.4010209@oracle.com> (raw)
In-Reply-To: <5575FBFD.7090208@oracle.com>
[-- Attachment #1: Type: text/plain, Size: 344 bytes --]
Hi again,
On 06/08/2015 10:33 PM, Paolo Carlini wrote:
>> Could you also check that we do the right thing for mem-initializers?
> Sure I will.
I think we have a similar issue in expand_default_init: exactly when
reshape_init is in order we fail to call it before digest_init. The
below also passes testing.
Thanks!
Paolo.
////////////////
[-- Attachment #2: patch_65815_2 --]
[-- Type: text/plain, Size: 2234 bytes --]
Index: cp/init.c
===================================================================
--- cp/init.c (revision 224234)
+++ cp/init.c (working copy)
@@ -1617,7 +1617,10 @@ expand_default_init (tree binfo, tree true_exp, tr
&& CP_AGGREGATE_TYPE_P (type))
/* A brace-enclosed initializer for an aggregate. In C++0x this can
happen for direct-initialization, too. */
- init = digest_init (type, init, complain);
+ {
+ init = reshape_init (type, init, complain);
+ init = digest_init (type, init, complain);
+ }
/* A CONSTRUCTOR of the target's type is a previously digested
initializer, whether that happened just above or in
Index: cp/typeck2.c
===================================================================
--- cp/typeck2.c (revision 224234)
+++ cp/typeck2.c (working copy)
@@ -1161,10 +1161,14 @@ digest_nsdmi_init (tree decl, tree init)
{
gcc_assert (TREE_CODE (decl) == FIELD_DECL);
+ tree type = TREE_TYPE (decl);
int flags = LOOKUP_IMPLICIT;
if (DIRECT_LIST_INIT_P (init))
flags = LOOKUP_NORMAL;
- init = digest_init_flags (TREE_TYPE (decl), init, flags);
+ if (BRACE_ENCLOSED_INITIALIZER_P (init)
+ && CP_AGGREGATE_TYPE_P (type))
+ init = reshape_init (type, init, tf_warning_or_error);
+ init = digest_init_flags (type, init, flags);
if (TREE_CODE (init) == TARGET_EXPR)
/* This represents the whole initialization. */
TARGET_EXPR_DIRECT_INIT_P (init) = true;
Index: testsuite/g++.dg/cpp0x/mem-init-aggr1.C
===================================================================
--- testsuite/g++.dg/cpp0x/mem-init-aggr1.C (revision 0)
+++ testsuite/g++.dg/cpp0x/mem-init-aggr1.C (working copy)
@@ -0,0 +1,10 @@
+// PR c++/65815
+// { dg-do compile { target c++11 } }
+
+struct array {
+ int data [2];
+};
+
+struct X : array {
+ X() : array{ 1, 2 } { }
+};
Index: testsuite/g++.dg/cpp0x/nsdmi-aggr1.C
===================================================================
--- testsuite/g++.dg/cpp0x/nsdmi-aggr1.C (revision 0)
+++ testsuite/g++.dg/cpp0x/nsdmi-aggr1.C (working copy)
@@ -0,0 +1,10 @@
+// PR c++/65815
+// { dg-do compile { target c++11 } }
+
+struct array {
+ int data [2];
+};
+
+struct X {
+ array a = { 1, 2 };
+};
next prev parent reply other threads:[~2015-06-08 23:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-22 19:57 Paolo Carlini
2015-06-08 15:53 ` [Ping] " Paolo Carlini
2015-06-08 16:51 ` Jason Merrill
2015-06-08 21:22 ` Paolo Carlini
2015-06-08 23:20 ` Paolo Carlini [this message]
2015-06-09 0:58 ` Paolo Carlini
2015-06-09 14:05 ` Jason Merrill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55761EB7.4010209@oracle.com \
--to=paolo.carlini@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).