From patchwork Wed May 4 22:20:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 94173 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 2A686B6EDF for ; Thu, 5 May 2011 08:20:43 +1000 (EST) Received: (qmail 6721 invoked by alias); 4 May 2011 22:20:42 -0000 Received: (qmail 6713 invoked by uid 22791); 4 May 2011 22:20:41 -0000 X-SWARE-Spam-Status: No, hits=-6.3 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, 04 May 2011 22:20:24 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p44MKODw014819 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 4 May 2011 18:20:24 -0400 Received: from [127.0.0.1] (ovpn-113-126.phx2.redhat.com [10.3.113.126]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p44MKNaM020824 for ; Wed, 4 May 2011 18:20:23 -0400 Message-ID: <4DC1D127.2040804@redhat.com> Date: Wed, 04 May 2011 18:20:23 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110421 Fedora/3.1.9-2.fc14 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/48749 (ICE regression in template) 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 The problem was that fixed_type_or_null was looking closely at things that aren't meant to be looked at closely when we're in templates, namely a COMPONENT_REF where operand 1 is an IDENTIFIER. In a template we're going to discard the conversion anyway once we decide it's OK, so we might as well take the easy way out. Tested x86_64-pc-linux-gnu, applying to trunk. commit 58f7b3e610d3fcc14e2c29ae6acf62c0c8a938bc Author: Jason Merrill Date: Wed May 4 15:45:12 2011 -0400 PR c++/48749 * class.c (resolves_to_fixed_type_p): Don't look closely in templates. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 9af238b..a67b34a 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5980,7 +5980,17 @@ resolves_to_fixed_type_p (tree instance, int* nonnull) { tree t = TREE_TYPE (instance); int cdtorp = 0; - tree fixed = fixed_type_or_null (instance, nonnull, &cdtorp); + tree fixed; + + if (processing_template_decl) + { + /* In a template we only care about the type of the result. */ + if (nonnull) + *nonnull = true; + return true; + } + + fixed = fixed_type_or_null (instance, nonnull, &cdtorp); if (fixed == NULL_TREE) return 0; if (POINTER_TYPE_P (t)) diff --git a/gcc/testsuite/g++.dg/conversion/base1.C b/gcc/testsuite/g++.dg/conversion/base1.C new file mode 100644 index 0000000..e236504 --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/base1.C @@ -0,0 +1,20 @@ +// PR c++/48749 + +struct Tuple3 +{ + float x; +}; + +struct Pos: virtual Tuple3 { }; + +struct TexCoords +{ + Pos pos; +}; + +template +void eval (const TexCoords &coords) +{ + const Pos &pos = coords.pos; + pos.x; +}