From: Paolo Carlini Date: Thu, 5 Apr 2018 17:08:21 +0000 (+0000) Subject: re PR c++/80956 (ICE with abstract class vector) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=61f84e25f6cbfb182bfaa4334d44f3c865c4c0b7;p=gcc.git re PR c++/80956 (ICE with abstract class vector) /cp 2018-04-05 Paolo Carlini 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 PR c++/80956 * g++.dg/cpp0x/initlist100.C: New. * g++.dg/cpp0x/initlist101.C: Likewise. From-SVN: r259137 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0d60ed00a7d..4065440c1d9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2018-04-05 Paolo Carlini + + 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 PR c++/84792 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index f2ada2768de..b22a3cc132e 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -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)); diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 9b5db3dc3aa..62f0b3f037b 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -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 , isn't a template"); + error ("declaration of % does not match " + "%<#include %>, isn't a template"); return error_mark_node; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a94044ebc3a..1acfe0c89ea 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-04-05 Paolo Carlini + + PR c++/80956 + * g++.dg/cpp0x/initlist100.C: New. + * g++.dg/cpp0x/initlist101.C: Likewise. + 2018-04-05 Paolo Carlini 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 index 00000000000..9d80a004c17 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist100.C @@ -0,0 +1,10 @@ +// PR c++/80956 +// { dg-do compile { target c++11 } } + +namespace std { +template class initializer_list; // { dg-message "declaration" } +} + +template struct B { B (std::initializer_list); }; +struct C { virtual int foo (); }; +struct D : C {} d { B { 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 index 00000000000..a0f355220d8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist101.C @@ -0,0 +1,8 @@ +// PR c++/80956 +// { dg-do compile { target c++11 } } + +#include + +template struct B { B (std::initializer_list); }; +struct C { virtual int foo (); }; +struct D : C {} d { B { D {} } }; // { dg-error "no matching" }