Commit 52912c91 by Paolo Carlini Committed by Paolo Carlini

re PR c++/85227 (ICE with structured binding of a forward declared variable)

/cp
2018-04-09  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/85227
	* decl.c (cp_finish_decomp): In a template, if the type is incomplete
	issue a pedwarn and defer trying to do bindings.

/testsuite
2018-04-09  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/85227
	* g++.dg/cpp1z/decomp44.C: New.
	* g++.dg/cpp1z/decomp45.C: Likewise.

From-SVN: r259259
parent f0caea48
2018-04-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/85227
* decl.c (cp_finish_decomp): In a template, if the type is incomplete
issue a pedwarn and defer trying to do bindings.
2018-04-09 Jason Merrill <jason@redhat.com>
PR c++/85279 - dump_expr doesn't understand decltype.
......
......@@ -7756,6 +7756,9 @@ cp_finish_decomp (tree decl, tree first, unsigned int count)
error_at (loc, "cannot decompose lambda closure type %qT", type);
goto error_out;
}
else if (processing_template_decl && !COMPLETE_TYPE_P (type))
pedwarn (loc, 0, "structured binding refers to incomplete class type %qT",
type);
else
{
tree btype = find_decomp_class_base (loc, type, NULL_TREE);
......
2018-04-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/85227
* g++.dg/cpp1z/decomp44.C: New.
* g++.dg/cpp1z/decomp45.C: Likewise.
2018-04-09 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/83064
......
// PR c++/85227
// { dg-do compile { target c++11 } }
// { dg-options "" }
extern struct A a;
template<int> void foo()
{
auto[i] = a; // { dg-warning "incomplete" }
} // { dg-warning "structured bindings only available with -std=c..17 or -std=gnu..17" "" { target c++14_down } .-1 }
// PR c++/85227
// { dg-do compile { target c++11 } }
// { dg-options "" }
extern struct A a;
template<int>
void f()
{
auto [x] = a; // { dg-warning "incomplete" }
} // { dg-warning "structured bindings only available with -std=c..17 or -std=gnu..17" "" { target c++14_down } .-1 }
struct A { int i; };
int main()
{
f<0>();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment