Skip to content
Snippets Groups Projects
Commit a6a15bc5 authored by Nathaniel Shead's avatar Nathaniel Shead
Browse files

c++: Disallow decomposition of lambda bases [PR90321]


Decomposition of lambda closure types is not allowed by
[dcl.struct.bind] p6, since members of a closure have no name.

r244909 made this an error, but missed the case where a lambda is used
as a base.  This patch moves the check to find_decomp_class_base to
handle this case.

As a drive-by improvement, we also slightly improve the diagnostics to
indicate why a base class was being inspected.  Ideally the diagnostic
would point directly at the relevant base, but there doesn't seem to be
an easy way to get this location just from the binfo so I don't worry
about that here.

	PR c++/90321

gcc/cp/ChangeLog:

	* decl.cc (find_decomp_class_base): Check for decomposing a
	lambda closure type.  Report base class chains if needed.
	(cp_finish_decomp): Remove no-longer-needed check.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/decomp62.C: New test.

Signed-off-by: default avatarNathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: default avatarMarek Polacek <polacek@redhat.com>
parent 7238b074
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment