From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116821 invoked by alias); 16 Mar 2016 22:45:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 116763 invoked by uid 89); 16 Mar 2016 22:45:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Resolve, sk:differe 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; Wed, 16 Mar 2016 22:45:02 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 6FDA97FD41; Wed, 16 Mar 2016 22:45:01 +0000 (UTC) Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2GMj098022687 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 16 Mar 2016 18:45:01 -0400 Subject: Re: [PATCH v3 10/11] [PR gdb/14441] gdb: gdbtypes: add rvalue references to overloading resolution To: Artemiy Volkov , gdb-patches@sourceware.org References: <1453229609-20159-1-git-send-email-artemiyv@acm.org> <1457147955-21871-1-git-send-email-artemiyv@acm.org> <1457147955-21871-11-git-send-email-artemiyv@acm.org> From: Keith Seitz Message-ID: <56E9E1EC.1000304@redhat.com> Date: Wed, 16 Mar 2016 22:45:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1457147955-21871-11-git-send-email-artemiyv@acm.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-03/txt/msg00280.txt.bz2 On 03/04/2016 07:19 PM, Artemiy Volkov wrote: > diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c > index ce4b9be..c5b8ab5 100644 > --- a/gdb/gdbtypes.c > +++ b/gdb/gdbtypes.c > @@ -3466,15 +3468,65 @@ rank_one_type (struct type *parm, struct type *arg, struct value *value) > { > struct rank rank = {0,0}; > > - if (types_equal (parm, arg)) > - return EXACT_MATCH_BADNESS; > - > /* Resolve typedefs */ > if (TYPE_CODE (parm) == TYPE_CODE_TYPEDEF) > parm = check_typedef (parm); > if (TYPE_CODE (arg) == TYPE_CODE_TYPEDEF) > arg = check_typedef (arg); > > + if (value != NULL) > + { > + /* An rvalue argument cannot be bound to a non-const lvalue > + reference parameter... */ > + if (VALUE_LVAL (value) == not_lval > + && TYPE_CODE (parm) == TYPE_CODE_REF > + && !TYPE_CONST (parm->main_type->target_type)) > + return INCOMPATIBLE_TYPE_BADNESS; > + > + /* ... and an lvalue argument cannot be bound to an rvalue > + reference parameter. [C++ 13.3.3.1.4p3] */ > + if (VALUE_LVAL (value) != not_lval > + && TYPE_CODE (parm) == TYPE_CODE_RVALUE_REF) > + return INCOMPATIBLE_TYPE_BADNESS; > + } > + > + if (types_equal (parm, arg)) > + return EXACT_MATCH_BADNESS; > + > + /* An lvalue reference to a function should get higher priority than an > + rvalue reference to a function. */ > + Two spaces after "." > + if (value != NULL && TYPE_CODE (arg) == TYPE_CODE_RVALUE_REF > + && TYPE_CODE (TYPE_TARGET_TYPE (arg)) == TYPE_CODE_FUNC) > + { > + return (sum_ranks (rank_one_type (parm, > + lookup_pointer_type (TYPE_TARGET_TYPE (arg)), NULL), > + DIFFERENT_REFERENCE_TYPE_BADNESS)); > + } > + > + /* If a conversion to one type of reference is an identity conversion, and a > + conversion to the second type of reference is a non-identity conversion, > + choose the first type. */ > + Same here. > + if (value != NULL && TYPE_IS_REFERENCE (parm) && TYPE_IS_REFERENCE (arg) > + && TYPE_CODE (parm) != TYPE_CODE (arg)) > + { > + return (sum_ranks (rank_one_type (TYPE_TARGET_TYPE (parm), > + TYPE_TARGET_TYPE (arg), NULL), DIFFERENT_REFERENCE_TYPE_BADNESS)); > + } > + > + /* An rvalue should be first tried to bind to an rvalue reference, and then to > + an lvalue reference. */ > + And here. > + if (value != NULL && TYPE_CODE (parm) == TYPE_CODE_REF > + && VALUE_LVAL (value) == not_lval) > + { > + if (TYPE_IS_REFERENCE (arg)) > + arg = TYPE_TARGET_TYPE (arg); > + return (sum_ranks (rank_one_type (TYPE_TARGET_TYPE (parm), arg, NULL), > + LVALUE_REFERENCE_TO_RVALUE_BINDING_BADNESS)); > + } > + > /* See through references, since we can almost make non-references > references. */ > > Other than that, this looks good to me. Keith