Patchwork C++ PATCH for c++/58162 (wrong error with NSDMI, const and move ctor)

login
register
mail settings
Submitter Jason Merrill
Date Oct. 31, 2013, 2:41 p.m.
Message ID <52726C0D.7010600@redhat.com>
Download mbox | patch
Permalink /patch/287505/
State New
Headers show

Comments

Jason Merrill - Oct. 31, 2013, 2:41 p.m.
We're building up the full initialization for the non-static data member 
in cp_parser_late_parse_one_default_arg, so we don't need to do it again 
when we use the NSDMI.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit a0065b92a8039a07eb0d5fa577b919e820d86590
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Sep 24 06:15:28 2013 -0500

    	PR c++/58162
    	* parser.c (cp_parser_late_parse_one_default_arg): Set
    	TARGET_EXPR_DIRECT_INIT_P.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 9e28ced..bbc8e75 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -23212,6 +23212,9 @@  cp_parser_late_parse_one_default_arg (cp_parser *parser, tree decl,
 	      && CONSTRUCTOR_IS_DIRECT_INIT (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;
 	}
     }
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi9.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi9.C
new file mode 100644
index 0000000..febe0ec
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi9.C
@@ -0,0 +1,13 @@ 
+// PR c++/58162
+// { dg-require-effective-target c++11 }
+
+struct A {
+ A();
+ A(A&&);
+};
+
+struct B {
+ A const a = A();
+};
+
+B b;