diff options
author | Sami Wagiaalla <swagiaal@redhat.com> | 2010-10-14 16:13:43 +0000 |
---|---|---|
committer | Sami Wagiaalla <swagiaal@redhat.com> | 2010-10-14 16:13:43 +0000 |
commit | 7062b0a0dfe70957e9cb04749efb627a3032c3f2 (patch) | |
tree | 304772526bc6562280716509edb63433a0bc3eab /gdb/testsuite/gdb.cp/converts.cc | |
parent | 5c3da5ea2ef28d1f272e737e5165d671149291a0 (diff) | |
download | binutils-gdb-7062b0a0dfe70957e9cb04749efb627a3032c3f2.tar.gz |
Fixed void* vs int* overload issue (PR C++/10343).
2010-10-14 Sami Wagiaalla <swagiaal@redhat.com>
* gdbtypes.h: Create BASE_PTR_CONVERSION_BADNESS.
* gdbtypes.c (rank_one_type): Move type comparison code out of here
to...
(types_equal): ...here. And changed it as follows:
Outside of typedefs type must be of the same TYPE_CODE.
When compairing two pointers or references they are equal if their
targets are equal.
Correct pointer conversions.
2010-10-14 Sami Wagiaalla <swagiaal@redhat.com>
* gdb.cp/converts.cc: New test program.
* gdb.cp/converts.exp: New test.
* gdb.cp/overload.exp: Added test for void* vs int*.
* gdb.cp/overload.exp: Ditto.
* gdb.cp/oranking.exp: Removed related kfail.
Diffstat (limited to 'gdb/testsuite/gdb.cp/converts.cc')
-rw-r--r-- | gdb/testsuite/gdb.cp/converts.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.cp/converts.cc b/gdb/testsuite/gdb.cp/converts.cc new file mode 100644 index 00000000000..b5e7bdea133 --- /dev/null +++ b/gdb/testsuite/gdb.cp/converts.cc @@ -0,0 +1,53 @@ +class A {}; +class B : public A {}; + +typedef A TA1; +typedef A TA2; +typedef TA2 TA3; + +int foo0_1 (TA1) { return 1; } +int foo0_2 (TA3) { return 2; } +int foo0_3 (A***) { return 3; } + +int foo1_1 (char *) {return 11;} +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 foo2_1 (char** ) {return 21;} +int foo2_2 (char[][1]) {return 22;} +int foo2_3 (char *[]) {return 23;} +int foo2_4 (int *[]) {return 24;} + +int main() +{ + + TA2 ta; // typedef to.. + foo0_1 (ta); // ..another typedef + foo0_2 (ta); // ..typedef of a typedef + + B*** bppp; // Pointer-to-pointer-to-pointer-to-derived.. +//foo0_3(bppp); // Pointer-to-pointer-to-pointer base. + foo0_3((A***)bppp); // to ensure that the function is emitted. + + char *a; // pointer to.. + B *bp; + foo1_1 (a); // ..pointer + foo1_2 (a); // ..array + foo1_3 ((int*)a); // ..pointer of wrong type + foo1_3 ((int*)bp); // ..pointer of wrong type + foo1_4 (bp); // ..ancestor pointer + foo1_5 (bp); // ..void pointer + foo1_6 ((void**)bp); // ..void pointer + + char **b; // pointer pointer to.. + char ba[1][1]; + foo1_5 (b); // ..void pointer + foo2_1 (b); // ..pointer pointer + foo2_2 (ba); // ..array of arrays + foo2_3 (b); // ..array of pointers + foo2_4 ((int**)b); // ..array of wrong pointers + return 0; // end of main +} |