From patchwork Thu Apr 28 15:13:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 93234 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id E20C7B6EF7 for ; Fri, 29 Apr 2011 01:13:48 +1000 (EST) Received: (qmail 19690 invoked by alias); 28 Apr 2011 15:13:46 -0000 Received: (qmail 19591 invoked by uid 22791); 28 Apr 2011 15:13:45 -0000 X-SWARE-Spam-Status: No, hits=-5.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 28 Apr 2011 15:13:31 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3SFDUdW020970 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 28 Apr 2011 11:13:31 -0400 Received: from localhost (ovpn-113-71.phx2.redhat.com [10.3.113.71]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p3SFDTrB023160 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 28 Apr 2011 11:13:30 -0400 Received: by localhost (Postfix, from userid 500) id 1CD9E2A0298; Thu, 28 Apr 2011 17:13:28 +0200 (CEST) From: Dodji Seketeli To: Jason Merrill Cc: GCC Patches Subject: [PATCH] Fix PR c++/48656 X-URL: http://www.redhat.com Date: Thu, 28 Apr 2011 17:13:27 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hello, At the moment G++ considers a call expression involving a member function which implicit 'this' pointer is type dependant, as being a type dependent expression (PR c++/47172). The problem in this PR is that it fails to recognize a BASELINK node as being a member function. As a result, the call expression A::f() in the example of the patch below is not considered type dependent and so finish_expr_stmt wrongly makes the call expression take the code path reserved for non-dependent expressions. The patch below adds the BASELINK case to the relevant test, but I am not sure if I am missing other cases of nodes that could represent a member function call expression. I ran a regression test with this patch (with make check) without bootstrap on x86_64-unknown-linux-gnu and I am currently running a full bootstrap & regression test against trunk. OK to commit to trunk and 4.6 if the test passes? gcc/cp/ * semantics.c (finish_call_expr): Don't forget BASELINK nodes when considering call expressions involving a member function. gcc/testsuite/ * gcc/testsuite/g++.dg/template/inherit7.C: New test case. --- gcc/cp/semantics.c | 3 ++- gcc/testsuite/g++.dg/template/inherit7.C | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/inherit7.C diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 16fabb8..5486dd3 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2039,7 +2039,8 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual, is not included in *ARGS even though it is considered to be part of the list of arguments. Note that this is related to CWG issues 515 and 1005. */ - || ((TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE) + || (((TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE) + || BASELINK_P (fn)) && current_class_ref && type_dependent_expression_p (current_class_ref))) { diff --git a/gcc/testsuite/g++.dg/template/inherit7.C b/gcc/testsuite/g++.dg/template/inherit7.C new file mode 100644 index 0000000..67afbca --- /dev/null +++ b/gcc/testsuite/g++.dg/template/inherit7.C @@ -0,0 +1,21 @@ +// Origin: PR c++/48656 +// { dg-options "-std=c++0x" } +// { dg-do compile } + +struct A { + int f(); + int f(int); +}; + +template struct B : A +{ +}; + +template struct C : B +{ + void + g() + { + A::f(); + } +};