From patchwork Wed Feb 16 23:53:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 83412 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 4F0FEB70F5 for ; Thu, 17 Feb 2011 10:53:57 +1100 (EST) Received: (qmail 17614 invoked by alias); 16 Feb 2011 23:53:55 -0000 Received: (qmail 17606 invoked by uid 22791); 16 Feb 2011 23:53:53 -0000 X-SWARE-Spam-Status: No, hits=-5.7 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; Wed, 16 Feb 2011 23:53:48 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1GNrlU7031253 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 16 Feb 2011 18:53:47 -0500 Received: from adjoa.redhat.com (ovpn-113-49.phx2.redhat.com [10.3.113.49]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p1GNriwB028658; Wed, 16 Feb 2011 18:53:46 -0500 From: Dodji Seketeli To: GCC Patches Cc: Jason Merrill Subject: Re: [PATCH] Fix PR c++/47172 References: <4D52DBB7.5000908@redhat.com> <4D5407D9.2060709@redhat.com> <4D543FCD.2020306@redhat.com> X-URL: http://www.redhat.com Date: Thu, 17 Feb 2011 00:53:44 +0100 In-Reply-To: (Dodji Seketeli's message of "Fri, 11 Feb 2011 20:43:48 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes 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 After the discussion we had on IRC I am bootstrapping and testing this patch instead. OK if it passes bootstrap and tests? diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index aa956c8..02b8d15 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -17921,7 +17921,7 @@ dependent_type_p_r (tree type) } /* Returns TRUE if TYPE is dependent, in the sense of - [temp.dep.type]. */ + [temp.dep.type]. Note that a NULL type is considered dependent. */ bool dependent_type_p (tree type) @@ -18193,7 +18193,10 @@ value_dependent_expression_p (tree expression) } /* Returns TRUE if the EXPRESSION is type-dependent, in the sense of - [temp.dep.expr]. */ + [temp.dep.expr]. Note that an expression with no type is + considered dependent. Other parts of the compiler arrange for an + expression with type-dependent subexpressions to have no type, so + this function doesn't have to be fully recursive. */ bool type_dependent_expression_p (tree expression) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 58a59ee..daa7280 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2028,8 +2028,19 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual, if (processing_template_decl) { + /* If the call expression is dependent, build a CALL_EXPR node + with no type; type_dependent_expression_p recognizes + expressions with no type as being dependent. */ if (type_dependent_expression_p (fn) - || any_type_dependent_arguments_p (*args)) + || any_type_dependent_arguments_p (*args) + /* For a non-static member function, we need to specifically + test the type dependency of the "this" pointer because it + 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) + && current_class_ref + && type_dependent_expression_p (current_class_ref))) { result = build_nt_call_vec (fn, *args); KOENIG_LOOKUP_P (result) = koenig_p; diff --git a/gcc/testsuite/g++.dg/template/inherit6.C b/gcc/testsuite/g++.dg/template/inherit6.C new file mode 100644 index 0000000..241a68e --- /dev/null +++ b/gcc/testsuite/g++.dg/template/inherit6.C @@ -0,0 +1,23 @@ +// Origin PR c++/47172 +// { dg-options "-std=c++0x" } +// { dg-do compile } + +struct A +{ + int f() const; +}; + +template +struct B : A { }; + +template +struct C : B +{ + void g(); +}; + +template +void C::g() +{ + A::f(); +}