From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20831 invoked by alias); 5 May 2011 23:08:30 -0000 Received: (qmail 20822 invoked by uid 22791); 5 May 2011 23:08:29 -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, 05 May 2011 23:08:11 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p45N8BS1031015 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 5 May 2011 19:08:11 -0400 Received: from localhost (ovpn-113-100.phx2.redhat.com [10.3.113.100]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p45N89ac003468 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 5 May 2011 19:08:11 -0400 Received: by localhost (Postfix, from userid 500) id 4736CDB55; Fri, 6 May 2011 01:08:08 +0200 (CEST) From: Dodji Seketeli To: GCC Patches Cc: Jason Merrill Subject: [PATCH] Fix PR c++/48574 X-URL: http://www.redhat.com Date: Thu, 05 May 2011 23:15:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg00475.txt.bz2 Hello, This is a leftover of the fix for PR c++/48574. When fold_non_dependent_expr sees the lvalue reference 'b' in the example of the patch below (because in finish_call_expr, make_args_non_dependent on 'b' calls build_non_dependent_expr which calls null_ptr_cst_p which calls fold_non_dependent_expr), it indirectly calls fixed_type_or_null. The problem is that fold_non_dependent_expr unsets processing_template_decl, so the type_dependent_expression_p test I have added to fix PR c++/48574 returns immediately. So this patch uses uses_template_parms instead of type_dependent_expression_p. Tested and bootstrapped on x86_64-unknown-linux-gnu against trunk and 4.6. OK to commit to trunk and to 4.6? gcc/cp/ PR c++/48574 * class.c (fixed_type_or_null): Use uses_template_parms to test if the instance is dependent. gcc/testsuite/ PR c++/48574 * g++.dg/template/dependent-expr8.C: New test case. --- gcc/cp/class.c | 2 +- gcc/testsuite/g++.dg/template/dependent-expr8.C | 25 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/dependent-expr8.C diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 9af238b..6fcc3c5 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5939,7 +5939,7 @@ fixed_type_or_null (tree instance, int *nonnull, int *cdtorp) itself. */ if (TREE_CODE (instance) == VAR_DECL && DECL_INITIAL (instance) - && !type_dependent_expression_p (DECL_INITIAL (instance)) + && !uses_template_parms (DECL_INITIAL (instance)) && !htab_find (ht, instance)) { tree type; diff --git a/gcc/testsuite/g++.dg/template/dependent-expr8.C b/gcc/testsuite/g++.dg/template/dependent-expr8.C new file mode 100644 index 0000000..20014d6 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/dependent-expr8.C @@ -0,0 +1,25 @@ +// Origin PR c++/48574 +// { dg-options "-std=c++0x" } +// { dg-do compile } + +struct A +{ + virtual int foo(); +}; + +void baz (int); + +template +void +bar(T x) +{ + A &b = *x; + baz (b.foo ()); +} + +void +foo() +{ + A a; + bar(&a); +} -- Dodji