* [C++ Patch] PR 65815
@ 2015-05-22 19:57 Paolo Carlini
2015-06-08 15:53 ` [Ping] " Paolo Carlini
2015-06-08 16:51 ` Jason Merrill
0 siblings, 2 replies; 7+ messages in thread
From: Paolo Carlini @ 2015-05-22 19:57 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill
[-- Attachment #1: Type: text/plain, Size: 379 bytes --]
Hi,
surprisingly, for NSDMIs we don't use reshape_init and we end-up
rejecting simple testcases like the below. It seems clear to me that we
should - consistently with the comment preceding digest_init too - but
I'm not 100% sure that digest_nsdmi_init is the best place for that.
Anyway, the below passes testing on x86_64-linux.
Thanks!
Paolo.
/////////////////////////
[-- Attachment #2: CL_65815 --]
[-- Type: text/plain, Size: 399 bytes --]
/cp
2015-05-22 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/65815
* typeck2.c (digest_nsdmi_init): On aggregates use reshape_init;
take a type, not a decl, as first argument.
* parser.c (cp_parser_late_parse_one_default_arg): Adjust call.
* init.c (get_nsdmi): Likewise.
/testsuite
2015-05-22 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/65815
* g++.dg/cpp0x/nsdmi-aggr1.C: New.
[-- Attachment #3: patch_65815 --]
[-- Type: text/plain, Size: 2426 bytes --]
Index: cp/init.c
===================================================================
--- cp/init.c (revision 223580)
+++ cp/init.c (working copy)
@@ -564,7 +564,7 @@ get_nsdmi (tree member, bool in_ctor)
tf_warning_or_error, member, /*function_p=*/false,
/*integral_constant_expression_p=*/false));
- init = digest_nsdmi_init (member, init);
+ init = digest_nsdmi_init (TREE_TYPE (member), init);
}
else
{
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 223580)
+++ cp/parser.c (working copy)
@@ -24278,7 +24283,7 @@ cp_parser_late_parse_one_default_arg (cp_parser *p
parsed_arg = check_default_argument (parmtype, parsed_arg,
tf_warning_or_error);
else
- parsed_arg = digest_nsdmi_init (decl, parsed_arg);
+ parsed_arg = digest_nsdmi_init (TREE_TYPE (decl), parsed_arg);
}
/* If the token stream has not been completely used up, then
Index: cp/typeck2.c
===================================================================
--- cp/typeck2.c (revision 223580)
+++ cp/typeck2.c (working copy)
@@ -1159,16 +1159,18 @@ digest_init_flags (tree type, tree init, int flags
return digest_init_r (type, init, false, flags, tf_warning_or_error);
}
-/* Process the initializer INIT for an NSDMI DECL (a FIELD_DECL). */
+/* Process the initializer INIT for an NSDMI decl of type TYPE. */
+
tree
-digest_nsdmi_init (tree decl, tree init)
+digest_nsdmi_init (tree type, tree init)
{
- gcc_assert (TREE_CODE (decl) == FIELD_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/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 };
+};
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Ping] [C++ Patch] PR 65815
2015-05-22 19:57 [C++ Patch] PR 65815 Paolo Carlini
@ 2015-06-08 15:53 ` Paolo Carlini
2015-06-08 16:51 ` Jason Merrill
1 sibling, 0 replies; 7+ messages in thread
From: Paolo Carlini @ 2015-06-08 15:53 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill
Hi,
gently pinging this...
On 05/22/2015 08:46 PM, Paolo Carlini wrote:
> Hi,
>
> surprisingly, for NSDMIs we don't use reshape_init and we end-up
> rejecting simple testcases like the below. It seems clear to me that
> we should - consistently with the comment preceding digest_init too -
> but I'm not 100% sure that digest_nsdmi_init is the best place for
> that. Anyway, the below passes testing on x86_64-linux.
https://gcc.gnu.org/ml/gcc-patches/2015-05/msg02158.html
Thanks!
Paolo.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [C++ Patch] PR 65815
2015-05-22 19:57 [C++ Patch] PR 65815 Paolo Carlini
2015-06-08 15:53 ` [Ping] " Paolo Carlini
@ 2015-06-08 16:51 ` Jason Merrill
2015-06-08 21:22 ` Paolo Carlini
1 sibling, 1 reply; 7+ messages in thread
From: Jason Merrill @ 2015-06-08 16:51 UTC (permalink / raw)
To: Paolo Carlini, gcc-patches
On 05/22/2015 02:46 PM, Paolo Carlini wrote:
> take a type, not a decl, as first argument.
Why? This complicates calls.
Could you also check that we do the right thing for mem-initializers?
Jason
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [C++ Patch] PR 65815
2015-06-08 16:51 ` Jason Merrill
@ 2015-06-08 21:22 ` Paolo Carlini
2015-06-08 23:20 ` Paolo Carlini
0 siblings, 1 reply; 7+ messages in thread
From: Paolo Carlini @ 2015-06-08 21:22 UTC (permalink / raw)
To: Jason Merrill, gcc-patches
Hi,
On 06/08/2015 06:16 PM, Jason Merrill wrote:
> On 05/22/2015 02:46 PM, Paolo Carlini wrote:
>> take a type, not a decl, as first argument.
>
> Why? This complicates calls.
Yes, but, on the other hand, it's more consistent with the arguments of
the various digest_init_*. Also, we don't really use the DECL per se,
*only* its TREE_TYPE in the body. Thus, all in all, I decided to propose
that, but sure, I don't have a strong opinion...
> Could you also check that we do the right thing for mem-initializers?
Sure I will.
Paolo.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [C++ Patch] PR 65815
2015-06-08 21:22 ` Paolo Carlini
@ 2015-06-08 23:20 ` Paolo Carlini
2015-06-09 0:58 ` Paolo Carlini
2015-06-09 14:05 ` Jason Merrill
0 siblings, 2 replies; 7+ messages in thread
From: Paolo Carlini @ 2015-06-08 23:20 UTC (permalink / raw)
To: Jason Merrill, gcc-patches
[-- 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 };
+};
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [C++ Patch] PR 65815
2015-06-08 23:20 ` Paolo Carlini
@ 2015-06-09 0:58 ` Paolo Carlini
2015-06-09 14:05 ` Jason Merrill
1 sibling, 0 replies; 7+ messages in thread
From: Paolo Carlini @ 2015-06-09 0:58 UTC (permalink / raw)
To: Jason Merrill, gcc-patches
.. in case isn't obvious: this case is already Ok:
struct array {
int data [2];
};
struct X {
X() : a{ 1, 2 } { }
array a;
};
because perform_member_init calls reshape_init.
Paolo.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [C++ Patch] PR 65815
2015-06-08 23:20 ` Paolo Carlini
2015-06-09 0:58 ` Paolo Carlini
@ 2015-06-09 14:05 ` Jason Merrill
1 sibling, 0 replies; 7+ messages in thread
From: Jason Merrill @ 2015-06-09 14:05 UTC (permalink / raw)
To: Paolo Carlini, gcc-patches
OK, thanks.
Jason
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-06-09 13:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-22 19:57 [C++ Patch] PR 65815 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
2015-06-09 0:58 ` Paolo Carlini
2015-06-09 14:05 ` Jason Merrill
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).