Patchwork C++ PATCH for c++/46696 (error with defaulted op= and arrays)

login
register
mail settings
Submitter Jason Merrill
Date May 25, 2011, 7:36 p.m.
Message ID <4DDD5A26.7090302@redhat.com>
Download mbox | patch
Permalink /patch/97404/
State New
Headers show

Comments

Jason Merrill - May 25, 2011, 7:36 p.m.
Another case where we now need to check DECL_DEFAULTED_FN rather than 
DECL_ARTIFICIAL.

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

Patch

commit 3ac89bd9f5f81b4d3ff293b337e7e9163d3402dd
Author: Jason Merrill <jason@redhat.com>
Date:   Wed May 25 12:05:03 2011 -0400

    	PR c++/46696
    	* typeck.c (cp_build_modify_expr): Check DECL_DEFAULTED_FN.

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 69b25d3..5fbb765 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -6748,7 +6748,7 @@  cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs,
 
       /* Allow array assignment in compiler-generated code.  */
       else if (!current_function_decl
-	       || !DECL_ARTIFICIAL (current_function_decl))
+	       || !DECL_DEFAULTED_FN (current_function_decl))
 	{
           /* This routine is used for both initialization and assignment.
              Make sure the diagnostic message differentiates the context.  */
diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted29.C b/gcc/testsuite/g++.dg/cpp0x/defaulted29.C
new file mode 100644
index 0000000..5fcf5b0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/defaulted29.C
@@ -0,0 +1,20 @@ 
+// PR c++/46696
+// { dg-options -std=c++0x }
+
+struct A
+{
+  A& operator= (A const&);
+};
+
+struct B
+{
+  A ar[1];
+  B& operator= (B const&) = default;
+};
+
+int main()
+{
+  B x;
+  B y;
+  y = x;
+}