From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21282 invoked by alias); 15 Oct 2010 14:46:08 -0000 Received: (qmail 21273 invoked by uid 22791); 15 Oct 2010 14:46:06 -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; Fri, 15 Oct 2010 14:45:52 +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.13.8/8.13.8) with ESMTP id o9FEjoAM000904 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 15 Oct 2010 10:45:50 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id o9FEjoBt023179 for ; Fri, 15 Oct 2010 10:45:50 -0400 Received: from [10.15.16.129] (dhcp-10-15-16-129.yyz.redhat.com [10.15.16.129]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o9FEjnYO013611 for ; Fri, 15 Oct 2010 10:45:49 -0400 Message-ID: <4CB8691D.3000209@redhat.com> Date: Fri, 15 Oct 2010 14:46:00 -0000 From: sami wagiaalla User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Lightning/1.0b2pre Thunderbird/3.1.2 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: Re: [patch 2/2] Fix overload resolution of int* vs void* References: <4C7BCD42.9070308@redhat.com> <4CAF6B73.5090800@redhat.com> <8339sgo1jl.fsf@gnu.org> <4CAF889C.1080404@redhat.com> <4CB4BE8D.1000001@redhat.com> <4CB5CD25.7080803@redhat.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------070701000107020009090900" X-IsSubscribed: yes 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 X-SW-Source: 2010-10/txt/msg00247.txt.bz2 This is a multi-part message in MIME format. --------------070701000107020009090900 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 381 > Sami> Having typed this out, I think POINTER_CONVERSION_BADNESS should be > Sami> renamed to BOOL_PTR_CONVERSION_BADNESS and given a rank of 3. And all > Sami> other conversions outlawed. I'll do this in and test it another > Sami> patch. This patch really only deals with the first clauses of the > Sami> nested switch statements. > > Thanks. Patch attached as promised. --------------070701000107020009090900 Content-Type: text/x-patch; name="overload_pointer_to_bool.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="overload_pointer_to_bool.patch" Content-length: 4223 Support pointer to bool conversion. 2010-10-13 Sami Wagiaalla * gdbtypes.h: Introduce BOOL_PTR_CONVERSION_BADNESS. * gdbtypes.c (rank_one_type): Use BOOL_PTR_CONVERSION_BADNESS for conversion. Make all other conversions illegal. 2010-10-13 Sami Wagiaalla * gdb.cp/converts.exp: Test pointer to bool conversion. Test pointer to long conversion. * gdb.cp/oranking.exp: Removed relevant kfail. diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index adced8e..5f6e6d8 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -2225,7 +2225,6 @@ rank_one_type (struct type *parm, struct type *arg) case TYPE_CODE_CHAR: case TYPE_CODE_RANGE: case TYPE_CODE_BOOL: - return POINTER_CONVERSION_BADNESS; default: return INCOMPATIBLE_TYPE_BADNESS; } @@ -2403,8 +2402,9 @@ rank_one_type (struct type *parm, struct type *arg) case TYPE_CODE_RANGE: case TYPE_CODE_ENUM: case TYPE_CODE_FLT: + return INCOMPATIBLE_TYPE_BADNESS; case TYPE_CODE_PTR: - return BOOLEAN_CONVERSION_BADNESS; + return BOOL_PTR_CONVERSION_BADNESS; case TYPE_CODE_BOOL: return 0; default: diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 62ade5f..6119114 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1409,12 +1409,10 @@ extern int is_unique_ancestor (struct type *, struct value *); #define FLOAT_CONVERSION_BADNESS 2 /* Badness of integer<->floating conversions */ #define INT_FLOAT_CONVERSION_BADNESS 2 -/* Badness of converting to a boolean */ -#define BOOLEAN_CONVERSION_BADNESS 2 -/* Badness of pointer conversion */ -#define POINTER_CONVERSION_BADNESS 2 /* Badness of conversion of pointer to void pointer */ #define VOID_PTR_CONVERSION_BADNESS 2 +/* Badness of conversion of pointer to boolean. */ +#define BOOL_PTR_CONVERSION_BADNESS 3 /* Badness of converting derived to base class */ #define BASE_CONVERSION_BADNESS 2 /* Badness of converting from non-reference to reference */ diff --git a/gdb/testsuite/gdb.cp/converts.cc b/gdb/testsuite/gdb.cp/converts.cc index b5e7bde..34b6927 100644 --- a/gdb/testsuite/gdb.cp/converts.cc +++ b/gdb/testsuite/gdb.cp/converts.cc @@ -14,7 +14,9 @@ int foo1_2 (char[]) {return 12;} int foo1_3 (int*) {return 13;} int foo1_4 (A*) {return 14;} int foo1_5 (void*) {return 15;} -int foo1_6 (void**) {return 15;} +int foo1_6 (void**) {return 16;} +int foo1_7 (bool) {return 17;} +int foo1_8 (long) {return 18;} int foo2_1 (char** ) {return 21;} int foo2_2 (char[][1]) {return 22;} @@ -40,7 +42,9 @@ int main() foo1_3 ((int*)bp); // ..pointer of wrong type foo1_4 (bp); // ..ancestor pointer foo1_5 (bp); // ..void pointer - foo1_6 ((void**)bp); // ..void pointer + foo1_6 ((void**)bp); // ..void pointer pointer + foo1_7 (bp); // ..boolean + foo1_8 ((long)bp); // ..long int char **b; // pointer pointer to.. char ba[1][1]; diff --git a/gdb/testsuite/gdb.cp/converts.exp b/gdb/testsuite/gdb.cp/converts.exp index 121bcad..4e4c2ea 100644 --- a/gdb/testsuite/gdb.cp/converts.exp +++ b/gdb/testsuite/gdb.cp/converts.exp @@ -40,6 +40,9 @@ gdb_test "p foo1_3 (a)" "Cannot resolve.*" "pointer to pointer of wrong type" gdb_test "p foo1_3 (bp)" "Cannot resolve.*" "pointer to pointer of wrong type" gdb_test "p foo1_4 (bp)" "= 14" "pointer to ancestor pointer" gdb_test "p foo1_5 (bp)" "= 15" "pointer to void pointer" +gdb_test "p foo1_6 (bp)" "Cannot resolve.*" "pointer to void pointer pointer" +gdb_test "p foo1_7 (bp)" "= 17" "pointer to boolean" +gdb_test "p foo1_8 (bp)" "Using non-standard.*" "pointer to long int" gdb_test "p foo1_5 (b)" "= 15" "pointer pointer to void pointer" gdb_test "p foo2_1 (b)" "= 21" "pointer pointer to pointer pointer" diff --git a/gdb/testsuite/gdb.cp/oranking.exp b/gdb/testsuite/gdb.cp/oranking.exp index f06933a..f1efb77 100644 --- a/gdb/testsuite/gdb.cp/oranking.exp +++ b/gdb/testsuite/gdb.cp/oranking.exp @@ -52,7 +52,6 @@ setup_kfail "gdb/12098" *-*-* gdb_test "p foo4(&a)" "24" gdb_test "p test5()" "26" -setup_kfail "gdb/12098" *-*-* gdb_test "p foo5(c)" "26" gdb_test "p test6()" "28" --------------070701000107020009090900--