This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]