re PR c++/80956 (ICE with abstract class vector)
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 5 Apr 2018 17:08:21 +0000 (17:08 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 5 Apr 2018 17:08:21 +0000 (17:08 +0000)
/cp
2018-04-05  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/80956
* call.c (convert_like_real): Fail gracefully for a broken
std::initializer_list, missing a definition.

* name-lookup.c (do_pushtag): Tweak message, use %< and %>.

/testsuite
2018-04-05  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/80956
* g++.dg/cpp0x/initlist100.C: New.
* g++.dg/cpp0x/initlist101.C: Likewise.

From-SVN: r259137

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/initlist100.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/initlist101.C [new file with mode: 0644]

index 0d60ed00a7de793623896b32384f1b1948ea7b92..4065440c1d9c24a9a337f49619bafe6fba3bc4de 100644 (file)
@@ -1,3 +1,11 @@
+2018-04-05  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/80956
+       * call.c (convert_like_real): Fail gracefully for a broken
+       std::initializer_list, missing a definition.
+
+       * name-lookup.c (do_pushtag): Tweak message, use %< and %>.
+
 2018-04-05  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/84792
index f2ada2768de726565110b8aa94533638f71feee3..b22a3cc132e34590e50ad125aa80294352b7e8d1 100644 (file)
@@ -6880,8 +6880,12 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
        if (array == error_mark_node)
          return error_mark_node;
 
-       /* Build up the initializer_list object.  */
-       totype = complete_type (totype);
+       /* Build up the initializer_list object.  Note: fail gracefully
+          if the object cannot be completed because, for example, no
+          definition is provided (c++/80956).  */
+       totype = complete_type_or_maybe_complain (totype, NULL_TREE, complain);
+       if (!totype)
+         return error_mark_node;
        field = next_initializable_field (TYPE_FIELDS (totype));
        CONSTRUCTOR_APPEND_ELT (vec, field, array);
        field = next_initializable_field (DECL_CHAIN (field));
index 9b5db3dc3aa78238f3ba3961c936f41f8d005a33..62f0b3f037b12c746349948d77c49c5cf400b717 100644 (file)
@@ -6476,8 +6476,8 @@ do_pushtag (tree name, tree type, tag_scope scope)
              && init_list_identifier == DECL_NAME (TYPE_NAME (type))
              && !CLASSTYPE_TEMPLATE_INFO (type))
            {
-             error ("declaration of std::initializer_list does not match "
-                    "#include <initializer_list>, isn't a template");
+             error ("declaration of %<std::initializer_list%> does not match "
+                    "%<#include <initializer_list>%>, isn't a template");
              return error_mark_node;
            }
        }
index a94044ebc3a7cc4e2e184057618ae6e6c4bafddf..1acfe0c89ea84b6494ea3492473043924baa5745 100644 (file)
@@ -1,3 +1,9 @@
+2018-04-05  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/80956
+       * g++.dg/cpp0x/initlist100.C: New.
+       * g++.dg/cpp0x/initlist101.C: Likewise.
+
 2018-04-05  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/84792
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist100.C b/gcc/testsuite/g++.dg/cpp0x/initlist100.C
new file mode 100644 (file)
index 0000000..9d80a00
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/80956
+// { dg-do compile { target c++11 } }
+
+namespace std {
+template <class> class initializer_list;  // { dg-message "declaration" }
+}
+
+template <typename T> struct B { B (std::initializer_list<T>); };
+struct C { virtual int foo (); };
+struct D : C {} d { B<C> { D {} } };  // { dg-error "incomplete|no matching" }
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist101.C b/gcc/testsuite/g++.dg/cpp0x/initlist101.C
new file mode 100644 (file)
index 0000000..a0f3552
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/80956
+// { dg-do compile { target c++11 } }
+
+#include <initializer_list>
+
+template <typename T> struct B { B (std::initializer_list<T>); };
+struct C { virtual int foo (); };
+struct D : C {} d { B<C> { D {} } };  // { dg-error "no matching" }