aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2014-05-20 19:20:59 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2014-05-20 19:20:59 +0000
commitf4cd9c518ba414724bacb1d936ba1676929fa52e (patch)
tree9702b7ba73d702d1ff68c785ac39e59b62e2c747 /gcc
parentf98732327cfaa9a50d292553f36417b46dc835b8 (diff)
downloadgcc-f4cd9c518ba414724bacb1d936ba1676929fa52e.zip
gcc-f4cd9c518ba414724bacb1d936ba1676929fa52e.tar.gz
gcc-f4cd9c518ba414724bacb1d936ba1676929fa52e.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/init.c16
-rw-r--r--gcc/cp/parser.c10
-rw-r--r--gcc/cp/typeck2.c16
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nsdmi-template11.C15
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nsdmi-template12.C17
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nsdmi-template13.C11
9 files changed, 90 insertions, 15 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index dd183cc..fb0d335 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 32a8afb..7d29c2c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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);
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 80764f9..42b25db 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -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);
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 0c9e113..d6bb518 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 72995e9..d50d93e 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -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. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cdb3d87..121cc19 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template11.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template11.C
new file mode 100644
index 0000000..60e53c4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template11.C
@@ -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;
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template12.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template12.C
new file mode 100644
index 0000000..5b87f42
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template12.C
@@ -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;
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template13.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template13.C
new file mode 100644
index 0000000..65ccd0a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template13.C
@@ -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;