diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2011-10-14 14:43:03 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2011-10-14 14:43:03 +0000 |
commit | 008d5fccd8a264d12330914f5b14e74a51c9ef03 (patch) | |
tree | 966c87c3a0905c1a73be4ebf2261795115117c51 | |
parent | e11a4c8086c3e6fadeb25950bffca82be527ed8b (diff) | |
download | gcc-008d5fccd8a264d12330914f5b14e74a51c9ef03.zip gcc-008d5fccd8a264d12330914f5b14e74a51c9ef03.tar.gz gcc-008d5fccd8a264d12330914f5b14e74a51c9ef03.tar.bz2 |
re PR c++/38174 (Missing some built-in candidates for operator overloading)
/cp
2011-10-14 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/38174
* call.c (add_builtin_candidate): If two pointers have a composite
pointer type, generate a single candidate with that type.
/testsuite
2011-10-14 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/38174
* g++.dg/overload/operator4.C: New.
From-SVN: r179984
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/call.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/overload/operator4.C | 14 |
4 files changed, 40 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9a214b5..aac66d5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-10-14 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/38174 + * call.c (add_builtin_candidate): If two pointers have a composite + pointer type, generate a single candidate with that type. + 2011-10-13 Jason Merrill <jason@redhat.com> PR c++/50614 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 7219afe..7e87bdf 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -2582,6 +2582,21 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code, || MAYBE_CLASS_TYPE_P (type1) || TREE_CODE (type1) == ENUMERAL_TYPE)) { + if (TYPE_PTR_P (type1) || TYPE_PTR_TO_MEMBER_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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2a475ab..e04f527 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-10-14 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/38174 + * g++.dg/overload/operator4.C: New. + 2011-10-14 David Alan Gilbert <david.gilbert@linaro.org> * gcc.dg/di-longlong64-sync-1.c: New test. diff --git a/gcc/testsuite/g++.dg/overload/operator4.C b/gcc/testsuite/g++.dg/overload/operator4.C new file mode 100644 index 0000000..3ec1eb4 --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/operator4.C @@ -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; +} |