aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorSami Wagiaalla <swagiaal@redhat.com>2010-10-19 16:07:25 +0000
committerSami Wagiaalla <swagiaal@redhat.com>2010-10-19 16:07:25 +0000
commit026ffab798b81c8b752a5b277361efec7b96b564 (patch)
tree780fd99d7b027c2a30c25d95101a430aa2476207 /gdb
parent20f5cfbdeace664dca0f967e4f20fa45e37947d5 (diff)
downloadgdb-026ffab798b81c8b752a5b277361efec7b96b564.zip
gdb-026ffab798b81c8b752a5b277361efec7b96b564.tar.gz
gdb-026ffab798b81c8b752a5b277361efec7b96b564.tar.bz2
Support pointer to bool conversion.
2010-10-19 Sami Wagiaalla <swagiaal@redhat.com> * 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-19 Sami Wagiaalla <swagiaal@redhat.com> * gdb.cp/converts.exp: Test pointer to bool conversion. Test pointer to long conversion. * gdb.cp/oranking.exp: Removed relevant kfail.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/gdbtypes.c4
-rw-r--r--gdb/gdbtypes.h6
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.cp/converts.cc8
-rw-r--r--gdb/testsuite/gdb.cp/converts.exp3
-rw-r--r--gdb/testsuite/gdb.cp/oranking.exp1
7 files changed, 26 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bff8559..d41d970 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2010-10-19 Sami Wagiaalla <swagiaal@redhat.com>
+
+ * 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-18 Doug Evans <dje@google.com>
* c-typeprint.c (c_type_print_base, case TYPE_CODE_TYPEDEF): Verify
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 204bab5..d08dbfe 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2256,7 +2256,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;
}
@@ -2434,8 +2433,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 e4dac49..5617a1d 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1415,12 +1415,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/ChangeLog b/gdb/testsuite/ChangeLog
index 9208bb4..824796e 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2010-10-19 Sami Wagiaalla <swagiaal@redhat.com>
+
+ * gdb.cp/converts.exp: Test pointer to bool conversion.
+ Test pointer to long conversion.
+ * gdb.cp/oranking.exp: Removed relevant kfail.
+
2010-10-18 Tom Tromey <tromey@redhat.com>
* gdb.python/py-prettyprint.exp (run_lang_tests): Test encoding
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"