DR 1591 PR c++/60051
authorJason Merrill <jason@redhat.com>
Fri, 21 Feb 2014 14:56:20 +0000 (09:56 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 21 Feb 2014 14:56:20 +0000 (09:56 -0500)
DR 1591
PR c++/60051
* pt.c (unify): Only unify if deducible.  Handle 0-length list.

From-SVN: r207998

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

index 9f04144..8a2cb16 100644 (file)
@@ -1,5 +1,9 @@
 2014-02-21  Jason Merrill  <jason@redhat.com>
 
+       DR 1591
+       PR c++/60051
+       * pt.c (unify): Only unify if deducible.  Handle 0-length list.
+
        PR c++/60250
        * parser.c (cp_parser_direct_declarator): Don't wrap a
        type-dependent expression in a NOP_EXPR.
index 4cf387a..0f576a5 100644 (file)
@@ -17262,14 +17262,16 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
                                   explain_p);
        }
 
-      if (TREE_CODE (parm) == ARRAY_TYPE)
+      if (TREE_CODE (parm) == ARRAY_TYPE
+         && deducible_array_bound (TYPE_DOMAIN (parm)))
        {
          /* Also deduce from the length of the initializer list.  */
          tree max = size_int (CONSTRUCTOR_NELTS (arg));
          tree idx = compute_array_index_type (NULL_TREE, max, tf_none);
-         if (TYPE_DOMAIN (parm) != NULL_TREE)
-           return unify_array_domain (tparms, targs, TYPE_DOMAIN (parm),
-                                      idx, explain_p);
+         if (idx == error_mark_node)
+           return unify_invalid (explain_p);
+         return unify_array_domain (tparms, targs, TYPE_DOMAIN (parm),
+                                    idx, explain_p);
        }
 
       /* If the std::initializer_list<T> deduction worked, replace the
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist80.C b/gcc/testsuite/g++.dg/cpp0x/initlist80.C
new file mode 100644 (file)
index 0000000..7947f1f
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/60051
+// { dg-require-effective-target c++11 }
+
+#include <initializer_list>
+
+auto x[2] = {};                        // { dg-error "" }