diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2018-04-05 17:08:21 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2018-04-05 17:08:21 +0000 |
commit | 61f84e25f6cbfb182bfaa4334d44f3c865c4c0b7 (patch) | |
tree | 902ce68a79ce3d3656c8f1e62d00ec1dd824c360 | |
parent | 3b4a12aa8a7c7298c0b6277dad82e1dd95857eb8 (diff) | |
download | gcc-61f84e25f6cbfb182bfaa4334d44f3c865c4c0b7.zip gcc-61f84e25f6cbfb182bfaa4334d44f3c865c4c0b7.tar.gz gcc-61f84e25f6cbfb182bfaa4334d44f3c865c4c0b7.tar.bz2 |
re PR c++/80956 (ICE with abstract class vector)
/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
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/call.c | 8 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist100.C | 10 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist101.C | 8 |
6 files changed, 40 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0d60ed0..4065440 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,13 @@ 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 * decl.c (grokdeclarator): Fix diagnostic about typedef name used as nested-name-specifier, keep type and TREE_TYPE (decl) in sync. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index f2ada27..b22a3cc 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 9b5db3d..62f0b3f 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 <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; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a94044e..1acfe0c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,11 @@ 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 * g++.dg/other/pr84792-1.C: New. * g++.dg/other/pr84792-2.C: Likewise. diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist100.C b/gcc/testsuite/g++.dg/cpp0x/initlist100.C new file mode 100644 index 0000000..9d80a00 --- /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> 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 index 0000000..a0f3552 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist101.C @@ -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" } |