Hi,

in the first one we pass a NULL_TREE to unify_array_domain: I think the right fix is simply not calling the function, as we do elsewhere. In the second, we forget to check that TREE_VALUE isn't NULL_TREE and we crash in the body of the conditional.

Tested x86_64-linux.

Thanks,
Paolo.

//////////////////////
/cp
2013-11-13  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/59080
        * pt.c (unify): Don't call unify_array_domain with a NULL_TREE
        third argument.

        PR c++/59096
        * pt.c (apply_late_template_attributes): Check that TREE_VALUE
        isn't NULL_TREE in the attribute_takes_identifier_p case.

/testsuite
2013-11-13  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/59080
        * g++.dg/cpp0x/initlist75.C: New.

        PR c++/59096
        * g++.dg/cpp0x/gen-attrs-57.C: New.
Index: cp/pt.c
===================================================================
--- cp/pt.c     (revision 204734)
+++ cp/pt.c     (working copy)
@@ -8613,7 +8613,8 @@ apply_late_template_attributes (tree *decl_p, tree
                 pass it through tsubst.  Attributes like mode, format,
                 cleanup and several target specific attributes expect it
                 unmodified.  */
-             else if (attribute_takes_identifier_p (get_attribute_name (t)))
+             else if (attribute_takes_identifier_p (get_attribute_name (t))
+                      && TREE_VALUE (t))
                {
                  tree chain
                    = tsubst_expr (TREE_CHAIN (TREE_VALUE (t)), args, complain,
@@ -17196,8 +17197,9 @@ unify (tree tparms, tree targs, tree parm, tree ar
          /* 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);
-         return unify_array_domain (tparms, targs, TYPE_DOMAIN (parm),
-                                    idx, explain_p);
+         if (TYPE_DOMAIN (parm) != NULL_TREE)
+           return unify_array_domain (tparms, targs, TYPE_DOMAIN (parm),
+                                      idx, explain_p);
        }
 
       /* If the std::initializer_list<T> deduction worked, replace the
Index: testsuite/g++.dg/cpp0x/gen-attrs-57.C
===================================================================
--- testsuite/g++.dg/cpp0x/gen-attrs-57.C       (revision 0)
+++ testsuite/g++.dg/cpp0x/gen-attrs-57.C       (working copy)
@@ -0,0 +1,9 @@
+// PR c++/59096
+// { dg-do compile { target c++11 } }
+
+template<typename T> struct A
+{
+  typedef T B [[mode]];   // { dg-warning "ignored" }
+};
+
+A<int>::B b;
Index: testsuite/g++.dg/cpp0x/initlist75.C
===================================================================
--- testsuite/g++.dg/cpp0x/initlist75.C (revision 0)
+++ testsuite/g++.dg/cpp0x/initlist75.C (working copy)
@@ -0,0 +1,6 @@
+// PR c++/59080
+// { dg-require-effective-target c++11 }
+
+#include <initializer_list>
+
+auto foo[] = {};    // { dg-error "auto|unable to deduce" }

Reply via email to