re PR c++/58753 (Brace-initializing a vector with a direct-initialization NSDMI doesn't work in a template)

/cp
2014-05-20  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58753
	PR c++/58930
	PR c++/58704
	* typeck2.c (digest_nsdmi_init): New.
	* parser.c (cp_parser_late_parse_one_default_arg): Use it.
	* init.c (get_nsdmi): Likewise.
	* cp-tree.h (digest_nsdmi_init): Declare.

/testsuite
2014-05-20  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58753
	PR c++/58930
	PR c++/58704
	* g++.dg/cpp0x/nsdmi-template11.C: New.
	* g++.dg/cpp0x/nsdmi-template12.C: Likewise.
	* g++.dg/cpp0x/nsdmi-template13.C: Likewise.

From-SVN: r210653
This commit is contained in:
Paolo Carlini 2014-05-20 19:20:59 +00:00 committed by Paolo Carlini
parent f98732327c
commit f4cd9c518b
9 changed files with 90 additions and 15 deletions

View File

@ -1,3 +1,13 @@
2014-05-20 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/58753
PR c++/58930
PR c++/58704
* typeck2.c (digest_nsdmi_init): New.
* parser.c (cp_parser_late_parse_one_default_arg): Use it.
* init.c (get_nsdmi): Likewise.
* cp-tree.h (digest_nsdmi_init): Declare.
2014-05-20 Jason Merrill <jason@redhat.com>
* typeck.c (get_member_function_from_ptrfunc): Don't try to look

View File

@ -6172,6 +6172,7 @@ extern tree store_init_value (tree, tree, vec<tree, va_gc>**, int);
extern void check_narrowing (tree, tree);
extern tree digest_init (tree, tree, tsubst_flags_t);
extern tree digest_init_flags (tree, tree, int);
extern tree digest_nsdmi_init (tree, tree);
extern tree build_scoped_ref (tree, tree, tree *);
extern tree build_x_arrow (location_t, tree,
tsubst_flags_t);

View File

@ -534,12 +534,16 @@ get_nsdmi (tree member, bool in_ctor)
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));
init = digest_nsdmi_init (member, init);
}
else
{
init = DECL_INITIAL (member);

View File

@ -23681,15 +23681,7 @@ cp_parser_late_parse_one_default_arg (cp_parser *parser, tree decl,
parsed_arg = check_default_argument (parmtype, parsed_arg,
tf_warning_or_error);
else
{
int flags = LOOKUP_IMPLICIT;
if (DIRECT_LIST_INIT_P (parsed_arg))
flags = LOOKUP_NORMAL;
parsed_arg = digest_init_flags (TREE_TYPE (decl), parsed_arg, flags);
if (TREE_CODE (parsed_arg) == TARGET_EXPR)
/* This represents the whole initialization. */
TARGET_EXPR_DIRECT_INIT_P (parsed_arg) = true;
}
parsed_arg = digest_nsdmi_init (decl, parsed_arg);
}
/* If the token stream has not been completely used up, then

View File

@ -1114,6 +1114,22 @@ 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). */
tree
digest_nsdmi_init (tree decl, 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 (TREE_CODE (init) == TARGET_EXPR)
/* This represents the whole initialization. */
TARGET_EXPR_DIRECT_INIT_P (init) = true;
return init;
}
/* Set of flags used within process_init_constructor to describe the
initializers. */

View File

@ -1,3 +1,12 @@
2014-05-20 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/58753
PR c++/58930
PR c++/58704
* g++.dg/cpp0x/nsdmi-template11.C: New.
* g++.dg/cpp0x/nsdmi-template12.C: Likewise.
* g++.dg/cpp0x/nsdmi-template13.C: Likewise.
2014-05-20 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/opt35.adb: New test.

View File

@ -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;

View File

@ -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;
}

View File

@ -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;