From b4fc57c2172dd78b3e1472b3b5fdbc69c7f20ac7 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 27 Apr 2010 21:27:04 +0000 Subject: [PATCH] * semantics.c (finish_qualified_id_expr): Use maybe_dummy_object rather than checking current_class_ref directly. (finish_call_expr): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158808 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 4 +++ gcc/cp/semantics.c | 32 ++++++++---------------- gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this2.C | 1 + 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4dd3df41ba6..9e74bc62919 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2010-04-27 Jason Merrill + * semantics.c (finish_qualified_id_expr): Use maybe_dummy_object + rather than checking current_class_ref directly. + (finish_call_expr): Likewise. + PR c++/43856 * name-lookup.c (qualify_lookup): Disqualify lambda op(). * class.c (current_nonlambda_class_type): New fn. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 7c039593608..7bcd75690fc 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1690,6 +1690,7 @@ finish_qualified_id_expr (tree qualifying_class, else if (BASELINK_P (expr) && !processing_template_decl) { tree fns; + tree ob; /* See if any of the functions are non-static members. */ fns = BASELINK_FUNCTIONS (expr); @@ -1697,10 +1698,10 @@ finish_qualified_id_expr (tree qualifying_class, fns = TREE_OPERAND (fns, 0); /* If so, the expression may be relative to 'this'. */ if (!shared_member_p (fns) - && current_class_ref - && DERIVED_FROM_P (qualifying_class, TREE_TYPE (current_class_ref))) + && (ob = maybe_dummy_object (qualifying_class, NULL), + !is_dummy_object (ob))) expr = (build_class_member_access_expr - (maybe_dummy_object (qualifying_class, NULL), + (ob, expr, BASELINK_ACCESS_BINFO (expr), /*preserve_reference=*/false, @@ -2002,31 +2003,18 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual, . operator.... [Otherwise] a contrived object of type T becomes the implied object argument. - This paragraph is unclear about this situation: + In this situation: struct A { void f(); }; struct B : public A {}; struct C : public A { void g() { B::f(); }}; - In particular, for `B::f', this paragraph does not make clear - whether "the class of that member function" refers to `A' or - to `B'. We believe it refers to `B'. */ - if (current_class_type - && DERIVED_FROM_P (BINFO_TYPE (BASELINK_ACCESS_BINFO (fn)), - current_class_type) - && current_class_ref) - object = maybe_dummy_object (BINFO_TYPE (BASELINK_ACCESS_BINFO (fn)), - NULL); - else - { - tree representative_fn; + "the class of that member function" refers to `A'. But 11.2 + [class.access.base] says that we need to convert 'this' to B* as + part of the access, so we pass 'B' to maybe_dummy_object. */ - representative_fn = BASELINK_FUNCTIONS (fn); - if (TREE_CODE (representative_fn) == TEMPLATE_ID_EXPR) - representative_fn = TREE_OPERAND (representative_fn, 0); - representative_fn = get_first_fn (representative_fn); - object = build_dummy_object (DECL_CONTEXT (representative_fn)); - } + object = maybe_dummy_object (BINFO_TYPE (BASELINK_ACCESS_BINFO (fn)), + NULL); if (processing_template_decl) { diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this2.C index ce4bda458c8..04fe474c733 100644 --- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this2.C +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this2.C @@ -10,6 +10,7 @@ struct S1 { [=]() { i; g(); + S1::g(); operator()(42); }; } -- 2.11.0