From patchwork Mon Jul 11 20:15:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 647077 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rpGZJ2Jc5z9sC3 for ; Tue, 12 Jul 2016 06:16:08 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=tksOnsXo; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=WnIf9haS63xHD0TUT38DhfanQHqL7 pQrBgyUR8T4OqgeZAJ6CZBMimQJH/mpEtGs0lz0PJb+oLneieQBZJuAmtODpLI92 vdU73OhfTe8i/uCq4yqOTZx/nmF6bf++49hMAabpFNUVjvfpSNfJyK/6KOmPaiuE rgdS0stQ0bJg+I= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=DoSHekqrckHz3wcmWAOXkvX/QHw=; b=tks OnsXoI82ha8rCExUYfhWSsVkTHYtzM5YNNwIaN5myiJwP+icTKIM2QXQyG6FqhSu Lpkq0o+tnkynqA9PrlxXAr00xayNI9aBxYF9JQV+b+6KcHSRhxv9+8C2i5Z38P0u 9sHg25/UOqJ8SKUd2T8/6sDazmeKdvSPmcN2Yexw= Received: (qmail 86104 invoked by alias); 11 Jul 2016 20:16:00 -0000 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 Received: (qmail 86090 invoked by uid 89); 11 Jul 2016 20:15:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=hunk X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 11 Jul 2016 20:15:58 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 86BA5C0624D8 for ; Mon, 11 Jul 2016 20:15:57 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-98.brq.redhat.com [10.40.204.98]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6BKFtPN007711 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 11 Jul 2016 16:15:56 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u6BKFsMH029497; Mon, 11 Jul 2016 22:15:54 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u6BKFqs9029496; Mon, 11 Jul 2016 22:15:52 +0200 Date: Mon, 11 Jul 2016 22:15:52 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix diagnostics ICE (PR c++/71835) Message-ID: <20160711201552.GT7387@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Hi! add_conv_candidate creates cand->fn which is not a FUNCTION_DECL, but some type, all spots in convert_like_real assume that if fn is non-NULL, it is some decl. Just a couple of lines above this hunk we even have a comment reminding us on cand->fn not having to be a decl: /* Since cand->fn will be a type, not a function, for a conversion function, we must be careful not to unconditionally look at DECL_NAME here. */ So, this patch uses just convert_like instead of convert_like_with_context if cand->fn is not a decl (or shall I test for TREE_CODE (cand->fn) == FUNCTION_DECL instead?). Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/6.2? 2016-07-11 Jakub Jelinek PR c++/71835 * call.c (build_op_call_1): Use convert_like_with_context only if cand->fn is a decl. * g++.dg/conversion/ambig3.C: New test. Jakub --- gcc/cp/call.c.jj 2016-07-11 11:14:28.000000000 +0200 +++ gcc/cp/call.c 2016-07-11 14:42:44.466186449 +0200 @@ -4406,8 +4406,11 @@ build_op_call_1 (tree obj, vecconvs[0], obj, cand->fn, -1, - complain); + if (DECL_P (cand->fn)) + obj = convert_like_with_context (cand->convs[0], obj, cand->fn, + -1, complain); + else + obj = convert_like (cand->convs[0], obj, complain); obj = convert_from_reference (obj); result = cp_build_function_call_vec (obj, args, complain); } --- gcc/testsuite/g++.dg/conversion/ambig3.C.jj 2016-07-11 14:47:26.668826075 +0200 +++ gcc/testsuite/g++.dg/conversion/ambig3.C 2016-07-11 14:46:49.000000000 +0200 @@ -0,0 +1,13 @@ +// PR c++/71835 +// { dg-do compile } + +typedef void T (int); +struct A { operator T * (); }; // { dg-message "candidate" } +struct B { operator T * (); }; // { dg-message "candidate" } +struct C : A, B {} c; + +void +foo () +{ + c (0); // { dg-error "is ambiguous" } +}