From: Jason Merrill Date: Mon, 17 Apr 2017 19:39:00 +0000 (-0400) Subject: PR c++/80415 - wrong error with default arg and array reference. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d478f1e4c947b2bdcd8e5cde8431f4c3dd79be60;p=gcc.git PR c++/80415 - wrong error with default arg and array reference. * tree.c (lvalue_kind): Return clk_class for an array prvalue. From-SVN: r246954 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index aa35f834782..c5db14c9dc1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2017-04-17 Jason Merrill + 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 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 57c1401a9d1..67dfea2c65b 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -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. */ }; diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 2edd5671c08..a1455c2b4b4 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -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 index 00000000000..12080a0ab4b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-array5.C @@ -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}; }