Hi,
On 05/19/2014 08:28 PM, Jason Merrill wrote:
How about doing digest_init in get_nsdmi, so that the conversion is
also exposed to walk_field_subobs?
Thus, good news: something as simple as the below passes testing, works
for the 2 bugs and for c++/58704 too. Thus, what else? Personally, I'm
not sure about a few things: whether reshape_init is needed (I tend to
think so, because later in perform_member_init certainly we use it);
whether digest_init (vs digest_init_flags, cmp the parser) is fine.
Thanks again!
Paolo.
//////////////////////
Index: cp/init.c
===================================================================
--- cp/init.c (revision 210641)
+++ cp/init.c (working copy)
@@ -529,17 +529,28 @@ tree
get_nsdmi (tree member, bool in_ctor)
{
tree init;
+ tree type = TREE_TYPE (member);
tree save_ccp = current_class_ptr;
tree save_ccr = current_class_ref;
if (!in_ctor)
inject_this_parameter (DECL_CONTEXT (member), TYPE_UNQUALIFIED);
if (DECL_LANG_SPECIFIC (member) && DECL_TEMPLATE_INFO (member))
- /* Do deferred instantiation of the NSDMI. */
- init = (tsubst_copy_and_build
- (DECL_INITIAL (DECL_TI_TEMPLATE (member)),
- DECL_TI_ARGS (member),
- tf_warning_or_error, member, /*function_p=*/false,
- /*integral_constant_expression_p=*/false));
+ {
+ /* Do deferred instantiation of the NSDMI. */
+ init = (tsubst_copy_and_build
+ (DECL_INITIAL (DECL_TI_TEMPLATE (member)),
+ DECL_TI_ARGS (member),
+ tf_warning_or_error, member, /*function_p=*/false,
+ /*integral_constant_expression_p=*/false));
+
+ if (TREE_TYPE (init) != type)
+ {
+ if (BRACE_ENCLOSED_INITIALIZER_P (init)
+ && CP_AGGREGATE_TYPE_P (type))
+ init = reshape_init (type, init, tf_warning_or_error);
+ init = digest_init (type, init, tf_warning_or_error);
+ }
+ }
else
{
init = DECL_INITIAL (member);
Index: testsuite/g++.dg/cpp0x/nsdmi-template11.C
===================================================================
--- testsuite/g++.dg/cpp0x/nsdmi-template11.C (revision 0)
+++ testsuite/g++.dg/cpp0x/nsdmi-template11.C (working copy)
@@ -0,0 +1,15 @@
+// PR c++/58930
+// { dg-do compile { target c++11 } }
+
+struct SampleModule
+{
+ explicit SampleModule (int);
+};
+
+template < typename >
+struct BaseHandler
+{
+ SampleModule module_ { 0 };
+};
+
+BaseHandler<int> a;
Index: testsuite/g++.dg/cpp0x/nsdmi-template12.C
===================================================================
--- testsuite/g++.dg/cpp0x/nsdmi-template12.C (revision 0)
+++ testsuite/g++.dg/cpp0x/nsdmi-template12.C (working copy)
@@ -0,0 +1,17 @@
+// PR c++/58753
+// { dg-do compile { target c++11 } }
+
+#include <initializer_list>
+
+template <class T>
+struct X {X(std::initializer_list<int>) {}};
+
+template <class zomg>
+class T {
+ X<T> x{1};
+};
+
+int main()
+{
+ T<int> t;
+}
Index: testsuite/g++.dg/cpp0x/nsdmi-template13.C
===================================================================
--- testsuite/g++.dg/cpp0x/nsdmi-template13.C (revision 0)
+++ testsuite/g++.dg/cpp0x/nsdmi-template13.C (working copy)
@@ -0,0 +1,11 @@
+// PR c++/58704
+// { dg-do compile { target c++11 } }
+
+struct A {};
+
+template<typename> struct B
+{
+ A a[1] = { };
+};
+
+B<int> b;