aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-01-23 14:52:23 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-01-23 14:52:23 +0100
commit941ae8b48eba8d5b6ff696f9bdc6c6cfff3247d0 (patch)
tree674742c8ae0d0392946a1255a04c3d022e9b59d4
parenta53d4f2004efef705435ea3e6bacfcca002d6c64 (diff)
downloadgcc-941ae8b48eba8d5b6ff696f9bdc6c6cfff3247d0.zip
gcc-941ae8b48eba8d5b6ff696f9bdc6c6cfff3247d0.tar.gz
gcc-941ae8b48eba8d5b6ff696f9bdc6c6cfff3247d0.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/decomp35.C35
4 files changed, 52 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index bd15f4c..5adf930 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2018-01-23 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/83958
+ * decl.c (cp_finish_decomp): Diagnose if reference structure binding
+ refers to incomplete type.
+
2018-01-23 Nathan Sidwell <nathan@acm.org>
Deprecate ARM-era for scope handling
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index f6fab42..5f197ef 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 bcbaa4c..8a997aa 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-23 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/83958
+ * g++.dg/cpp1z/decomp35.C: New test.
+
2018-01-23 Nathan Sidwell <nathan@acm.org>
* 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 0000000..844ad43
--- /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 <typename = void> struct A;
+class B;
+template <typename, typename, typename = A<>> class C;
+template <typename, typename> struct D;
+template <typename T, typename U, typename V, typename, typename, typename W>
+struct E {
+ using X = W;
+ X operator* ();
+ T operator++ ();
+ template <typename P, typename R, typename S, typename Q>
+ bool operator!= (E<P, U, V, R, S, Q>);
+};
+template <typename T, typename U, typename>
+struct F {
+ class G;
+ using H = D<T, U>;
+ using I = E<G, T, U, G, H, H &>;
+ class G : public I {};
+ G begin ();
+ G end ();
+};
+template <typename T, typename U, typename V> struct C : F<T, U, V> {
+ using J = F<T, U, V>;
+ using J::begin;
+ using J::end;
+};
+using K = class L;
+struct M {
+ void foo () { for (auto & [ a ] : m) {} } // { dg-error "incomplete type" }
+ C<K, B> m; // { dg-warning "only available with" "" { target c++14_down } .-1 }
+};