Skip to content
Snippets Groups Projects
Commit 9bc6b23d authored by Patrick Palka's avatar Patrick Palka
Browse files

c++: synthesized_method_walk context independence [PR113908]


In the second testcase below, during ahead of time checking of the
non-dependent new-expr we synthesize B's copy ctor, which we expect to
get defined as deleted since A's copy ctor is inaccessible.  But during
access checking thereof, enforce_access incorrectly decides to defer it
since we're in a template context according to current_template_parms
(before r14-557 it checked processing_template_decl which got cleared
from implicitly_declare_fn), which leads to the access check leaking out
to the template context that triggered the synthesization, and B's copy
ctor getting declared as non-deleted.

This patch fixes this by using maybe_push_to_top_level to clear the
context (including current_template_parms) before proceeding with the
synthesization.  We could do this from implicitly_declare_fn, but it's
better to do it more generally from synthesized_method_walk for sake of
its other callers.

This turns out to fix PR113332 as well: there the lambda context
triggering synthesization was causing maybe_dummy_object to misbehave,
but now synthesization is sufficiently context-independent.

	PR c++/113908
	PR c++/113332

gcc/cp/ChangeLog:

	* method.cc (synthesized_method_walk): Use maybe_push_to_top_level.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/lambda/lambda-nsdmi11.C: New test.
	* g++.dg/template/non-dependent31.C: New test.

Reviewed-by: default avatarJason Merrill <jason@redhat.com>
parent ad7a365a
No related branches found
No related tags found
No related merge requests found
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