OSDN Git Service

PR c++/58639
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Jan 2014 13:40:06 +0000 (13:40 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Jan 2014 13:40:06 +0000 (13:40 +0000)
* call.c (build_aggr_conv): Reject value-initialization of reference.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@207183 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/cpp0x/initlist78.C [new file with mode: 0644]

index 61bb61d..00d18f2 100644 (file)
@@ -1,3 +1,8 @@
+2014-01-27  Jason Merrill  <jason@redhat.com>
+
+       PR c++/58639
+       * call.c (build_aggr_conv): Reject value-initialization of reference.
+
 2013-10-25  Tom de Vries  <tom@codesourcery.com>
 
        PR c++/58282
index f49851d..d655983 100644 (file)
@@ -894,6 +894,9 @@ build_aggr_conv (tree type, tree ctor, int flags)
 
       if (i < CONSTRUCTOR_NELTS (ctor))
        val = CONSTRUCTOR_ELT (ctor, i)->value;
+      else if (TREE_CODE (ftype) == REFERENCE_TYPE)
+       /* Value-initialization of reference is ill-formed.  */
+       return NULL;
       else
        {
          if (empty_ctor == NULL_TREE)
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist78.C b/gcc/testsuite/g++.dg/cpp0x/initlist78.C
new file mode 100644 (file)
index 0000000..648ec53
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/58639
+// { dg-require-effective-target c++11 }
+
+struct node {
+  node &parent;
+};
+
+struct vector {
+  node n;
+};
+
+vector v({});                  // { dg-error "" }