PR c++/80415 - wrong error with default arg and array reference.
authorJason Merrill <jason@redhat.com>
Mon, 17 Apr 2017 19:39:00 +0000 (15:39 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 17 Apr 2017 19:39:00 +0000 (15:39 -0400)
* tree.c (lvalue_kind): Return clk_class for an array prvalue.

From-SVN: r246954

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/tree.c
gcc/testsuite/g++.dg/cpp0x/initlist-array5.C [new file with mode: 0644]

index aa35f83..c5db14c 100644 (file)
@@ -1,5 +1,8 @@
 2017-04-17  Jason Merrill  <jason@redhat.com>
 
+       PR c++/80415 - wrong error with default arg and array reference.
+       * tree.c (lvalue_kind): Return clk_class for an array prvalue.
+
        * pt.c (tsubst_init): Set TARGET_EXPR_DIRECT_INIT_P.
 
 2017-04-15  Alexandre Oliva <aoliva@redhat.com>
index 57c1401..67dfea2 100644 (file)
@@ -4677,7 +4677,7 @@ enum cp_lvalue_kind_flags {
   clk_none = 0,     /* Things that are not an lvalue.  */
   clk_ordinary = 1, /* An ordinary lvalue.  */
   clk_rvalueref = 2,/* An xvalue (rvalue formed using an rvalue reference) */
-  clk_class = 4,    /* A prvalue of class-type.  */
+  clk_class = 4,    /* A prvalue of class or array type.  */
   clk_bitfield = 8, /* An lvalue for a bit-field.  */
   clk_packed = 16   /* An lvalue for a packed field.  */
 };
index 2edd567..a1455c2 100644 (file)
@@ -243,7 +243,8 @@ lvalue_kind (const_tree ref)
     default:
       if (!TREE_TYPE (ref))
        return clk_none;
-      if (CLASS_TYPE_P (TREE_TYPE (ref)))
+      if (CLASS_TYPE_P (TREE_TYPE (ref))
+         || TREE_CODE (TREE_TYPE (ref)) == ARRAY_TYPE)
        return clk_class;
       break;
     }
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-array5.C b/gcc/testsuite/g++.dg/cpp0x/initlist-array5.C
new file mode 100644 (file)
index 0000000..12080a0
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/80415
+// { dg-do compile { target c++11 } }
+
+struct A {
+  A(int, int, const int (&)[1] = {});
+};
+A fn1() { return {0, 0}; }