Commit 08afbd3b by Jason Merrill Committed by Jason Merrill

Core 1612

	Core 1612
	* semantics.c (finish_id_expression): Reject capture of anonymous
	union member.

From-SVN: r198153
parent c10f4193
2013-04-22 Jason Merrill <jason@redhat.com>
Core 1612
* semantics.c (finish_id_expression): Reject capture of anonymous
union member.
Core 1609
* decl2.c (check_default_args): Check for pack expansion.
......
......@@ -3105,6 +3105,12 @@ finish_id_expression (tree id_expression,
= decl_function_context (containing_function);
}
if (lambda_expr && TREE_CODE (decl) == VAR_DECL
&& DECL_ANON_UNION_VAR_P (decl))
{
error ("cannot capture member %qD of anonymous union", decl);
return error_mark_node;
}
if (context == containing_function)
{
decl = add_default_capture (lambda_stack,
......
// DR 1612
// { dg-require-effective-target c++11 }
int main() {
static int result;
struct A { int x; };
struct B { int y; };
union {
A a; B b;
};
a.x = 1;
[=]() mutable {
a.x = 2; // { dg-error "anonymous union" }
result = b.y; // { dg-error "anonymous union" }
}();
if (result == 1) return 0;
throw 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