From patchwork Sun Feb 20 23:16:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 83769 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 9B040B711A for ; Mon, 21 Feb 2011 10:16:51 +1100 (EST) Received: (qmail 31017 invoked by alias); 20 Feb 2011 23:16:48 -0000 Received: (qmail 31002 invoked by uid 22791); 20 Feb 2011 23:16:47 -0000 X-SWARE-Spam-Status: No, hits=-6.2 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; Sun, 20 Feb 2011 23:16:41 +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 p1KNGd2T020705 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 20 Feb 2011 18:16:39 -0500 Received: from [127.0.0.1] (ovpn-113-43.phx2.redhat.com [10.3.113.43]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p1KNGdsK014847 for ; Sun, 20 Feb 2011 18:16:39 -0500 Message-ID: <4D61A0D6.7030605@redhat.com> Date: Sun, 20 Feb 2011 18:16:38 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/47703 (ICE on overload failure involving function pointer conversion) 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 This bug was reported in the context of C++0x lambdas, but affects any class with a conversion to function pointer. We were trying to get the source position of the pointer type and crashing. Tested x86_64-pc-linux-gnu, applied to trunk. commit 1686cec0169c6d65a0838a6c60b6e2765b4ce67c Author: Jason Merrill Date: Sun Feb 20 17:33:23 2011 -0500 PR c++/47703 * error.c (location_of): Handle non-tagged types. diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 3e91115..28305d2 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -2493,7 +2493,11 @@ location_of (tree t) if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (t)) t = DECL_CONTEXT (t); else if (TYPE_P (t)) - t = TYPE_MAIN_DECL (t); + { + t = TYPE_MAIN_DECL (t); + if (t == NULL_TREE) + return input_location; + } else if (TREE_CODE (t) == OVERLOAD) t = OVL_FUNCTION (t); diff --git a/gcc/testsuite/g++.dg/overload/conv-op1.C b/gcc/testsuite/g++.dg/overload/conv-op1.C new file mode 100644 index 0000000..6a63cba --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/conv-op1.C @@ -0,0 +1,17 @@ +// PR c++/47703 + +typedef void (*pfn)(int &); + +struct A +{ + operator pfn() { return 0; } +}; + +void f() +{ + const int i = 42; + A()(i); // { dg-message "" } +} + +// { dg-prune-output "no match" } +// { dg-prune-output "candidate" }