From: Jakub Jelinek Date: Tue, 23 Jan 2018 13:52:23 +0000 (+0100) Subject: re PR c++/83958 (ICE: Segmentation fault (in find_decomp_class_base)) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=941ae8b48eba8d5b6ff696f9bdc6c6cfff3247d0;p=gcc.git re PR c++/83958 (ICE: Segmentation fault (in find_decomp_class_base)) PR c++/83958 * decl.c (cp_finish_decomp): Diagnose if reference structure binding refers to incomplete type. * g++.dg/cpp1z/decomp35.C: New test. From-SVN: r256984 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bd15f4c045a..5adf93075d5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-01-23 Jakub Jelinek + + PR c++/83958 + * decl.c (cp_finish_decomp): Diagnose if reference structure binding + refers to incomplete type. + 2018-01-23 Nathan Sidwell Deprecate ARM-era for scope handling diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f6fab422d17..5f197ef68d8 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7435,6 +7435,12 @@ cp_finish_decomp (tree decl, tree first, unsigned int count) type = complete_type (TREE_TYPE (type)); if (type == error_mark_node) goto error_out; + if (!COMPLETE_TYPE_P (type)) + { + error_at (loc, "structured binding refers to incomplete type %qT", + type); + goto error_out; + } } tree eltype = NULL_TREE; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bcbaa4c6003..8a997aa8614 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-23 Jakub Jelinek + + PR c++/83958 + * g++.dg/cpp1z/decomp35.C: New test. + 2018-01-23 Nathan Sidwell * g++.dg/cpp0x/range-for10.C: Adjust. diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp35.C b/gcc/testsuite/g++.dg/cpp1z/decomp35.C new file mode 100644 index 00000000000..844ad43e141 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/decomp35.C @@ -0,0 +1,35 @@ +// PR c++/83958 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +template struct A; +class B; +template > class C; +template struct D; +template +struct E { + using X = W; + X operator* (); + T operator++ (); + template + bool operator!= (E); +}; +template +struct F { + class G; + using H = D; + using I = E; + class G : public I {}; + G begin (); + G end (); +}; +template struct C : F { + using J = F; + using J::begin; + using J::end; +}; +using K = class L; +struct M { + void foo () { for (auto & [ a ] : m) {} } // { dg-error "incomplete type" } + C m; // { dg-warning "only available with" "" { target c++14_down } .-1 } +};