From patchwork Fri Oct 14 02:37:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 119681 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 BD6EAB6F85 for ; Fri, 14 Oct 2011 13:40:03 +1100 (EST) Received: (qmail 29927 invoked by alias); 14 Oct 2011 02:40:00 -0000 Received: (qmail 29919 invoked by uid 22791); 14 Oct 2011 02:39:59 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rcsinet15.oracle.com (HELO rcsinet15.oracle.com) (148.87.113.117) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 14 Oct 2011 02:39:44 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by rcsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id p9E2dgU9003311 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 14 Oct 2011 02:39:43 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id p9E2dfdu021586 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 14 Oct 2011 02:39:41 GMT Received: from abhmt103.oracle.com (abhmt103.oracle.com [141.146.116.55]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id p9E2dZGj000898; Thu, 13 Oct 2011 21:39:35 -0500 Received: from [192.168.1.4] (/79.53.234.225) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 13 Oct 2011 19:39:35 -0700 Message-ID: <4E97A081.6060200@oracle.com> Date: Fri, 14 Oct 2011 04:37:53 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch / RFC] PR 38174 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 Hi, so, assuming I understood correctly Jason's tips (thanks again for your patience ;) the fix for this pretty old issue seems even simpler than I guessed at triage time, because we already have available composite_pointer_type, doing all the real work. The below passes the testsuite on x86_64-linux. What do you think? Paolo. ///////////////////// Index: testsuite/g++.dg/overload/operator4.C =================================================================== --- testsuite/g++.dg/overload/operator4.C (revision 0) +++ testsuite/g++.dg/overload/operator4.C (revision 0) @@ -0,0 +1,14 @@ +// PR c++/38174 + +struct VolatileIntPtr { + operator int volatile *(); +}; + +struct ConstIntPtr { + operator int const *(); +}; + +void test_with_ptrs(VolatileIntPtr vip, ConstIntPtr cip) { + bool b1 = (vip == cip); + long p1 = vip - cip; +} Index: cp/call.c =================================================================== --- cp/call.c (revision 179947) +++ cp/call.c (working copy) @@ -2582,6 +2582,23 @@ add_builtin_candidate (struct z_candidate **candid || MAYBE_CLASS_TYPE_P (type1) || TREE_CODE (type1) == ENUMERAL_TYPE)) { + if ((TYPE_PTR_P (type1) && TYPE_PTR_P (type2)) + || (TYPE_PTRMEM_P (type1) && TYPE_PTRMEM_P (type2)) + || TYPE_PTRMEMFUNC_P (type1)) + { + tree cptype = composite_pointer_type (type1, type2, + error_mark_node, + error_mark_node, + CPO_CONVERSION, + tf_none); + if (cptype != error_mark_node) + { + build_builtin_candidate + (candidates, fnname, cptype, cptype, args, argtypes, flags); + return; + } + } + build_builtin_candidate (candidates, fnname, type1, type1, args, argtypes, flags); build_builtin_candidate