diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-12-15 20:41:45 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-12-15 20:41:45 +0100 |
commit | e3a661b45e8d9baf96bef773e214f4c41581bc22 (patch) | |
tree | 109ff2c4cf011fe601b51b2963b60b4147cf9296 /gcc | |
parent | 32151c3f1b8b394b16b3d396a781e65426dd8f45 (diff) | |
download | gcc-e3a661b45e8d9baf96bef773e214f4c41581bc22.zip gcc-e3a661b45e8d9baf96bef773e214f4c41581bc22.tar.gz gcc-e3a661b45e8d9baf96bef773e214f4c41581bc22.tar.bz2 |
re PR c++/83217 (Compiler segfault: structured binding by reference to a templated type via a pointer)
PR c++/83217
* decl.c (cp_finish_decomp): If decl's type is REFERENCE_TYPE,
call complete_type (TREE_TYPE (type)).
* g++.dg/cpp1z/decomp33.C: New test.
From-SVN: r255702
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/decl.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1z/decomp33.C | 21 |
4 files changed, 31 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 25d7f58..1108aeb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-12-15 Jakub Jelinek <jakub@redhat.com> + PR c++/83217 + * decl.c (cp_finish_decomp): If decl's type is REFERENCE_TYPE, + call complete_type (TREE_TYPE (type)). + * tree.c (cxx_attribute_table, std_attribute_table): Swap affects_type_identity and handler fields, adjust comments. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 63a7b92..5df16bb 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7404,7 +7404,9 @@ cp_finish_decomp (tree decl, tree first, unsigned int count) if (TREE_CODE (type) == REFERENCE_TYPE) { dexp = convert_from_reference (dexp); - type = TREE_TYPE (type); + type = complete_type (TREE_TYPE (type)); + if (type == error_mark_node) + goto error_out; } tree eltype = NULL_TREE; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3d037b5..cd208ff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-12-15 Jakub Jelinek <jakub@redhat.com> + PR c++/83217 + * g++.dg/cpp1z/decomp33.C: New test. + PR tree-optimization/80631 * gcc.target/i386/avx2-pr80631.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp33.C b/gcc/testsuite/g++.dg/cpp1z/decomp33.C new file mode 100644 index 0000000..6429108 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/decomp33.C @@ -0,0 +1,21 @@ +// PR c++/83217 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +template <typename T> +struct S +{ + T a; +}; + +void +foo (S<int> *b) +{ + auto & [c] = *b; // { dg-warning "structured bindings only available with" "" { target c++14_down } } +} + +void +bar (S<char> *d) +{ + auto [e] = *d; // { dg-warning "structured bindings only available with" "" { target c++14_down } } +} |