diff options
author | Sami Wagiaalla <swagiaal@redhat.com> | 2010-06-07 16:11:35 +0000 |
---|---|---|
committer | Sami Wagiaalla <swagiaal@redhat.com> | 2010-06-07 16:11:35 +0000 |
commit | 4c3376c84943b8102da4237141dab7f1595912ca (patch) | |
tree | fc4936a3a61d60b2a60379e534e7081099969bb2 /gdb/testsuite/gdb.cp/operator.cc | |
parent | 0f32ea4ce3309801590068305e7c8d7aeb495f2f (diff) | |
download | fsf-binutils-gdb-4c3376c84943b8102da4237141dab7f1595912ca.zip fsf-binutils-gdb-4c3376c84943b8102da4237141dab7f1595912ca.tar.gz fsf-binutils-gdb-4c3376c84943b8102da4237141dab7f1595912ca.tar.bz2 |
Test and support all cpp operator types.
2010-06-07 Sami Wagiaalla <swagiaal@redhat.com>
* value.h: Created oload_search_type enum.
(find_overload_match): Use oload_search_type enum.
* valops.c (find_overload_match): Support combined member and
non-member search.
* eval.c (evaluate_subexp_standard): Calls to
find_overload_match now use oload_search_type enum.
(oload_method_static): Verify index is a proper value.
* valarith.c (value_user_defined_cpp_op): Search for and handle
both member and non-member operators.
(value_user_defined_cpp_op): New function.
(value_user_defined_op): New function.
(value_x_unop): Use value_user_defined_op.
(value_x_binop): Ditto.
* cp-support.c (make_symbol_overload_list_using): Added block
iteration.
Add check for namespace aliases and imported declarations.
2010-06-07 Sami Wagiaalla <swagiaal@redhat.com>
* gdb.cp/koenig.exp: Test for ADL operators.
* gdb.cp/koenig.cc: Added ADL operators.
* gdb.cp/operator.exp: New test.
* gdb.cp/operator.cc: New test.
Diffstat (limited to 'gdb/testsuite/gdb.cp/operator.cc')
-rw-r--r-- | gdb/testsuite/gdb.cp/operator.cc | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.cp/operator.cc b/gdb/testsuite/gdb.cp/operator.cc new file mode 100644 index 0000000..cc925a0 --- /dev/null +++ b/gdb/testsuite/gdb.cp/operator.cc @@ -0,0 +1,195 @@ +class A +{ +}; + +int operator== (A, int) +{ + return 11; +} + +int operator== (A, char) +{ + return 12; +} + +//------------------ + +namespace B +{ + class C + { + }; + + int operator== (C, int) + { + return 22; + } + + int operator== (C, char) + { + return 23; + } + + namespace BD + { + int operator== (C, int) + { + return 24; + } + } +} + +//------------------ + +class D +{ +}; +namespace +{ + int operator== (D, int) + { + return 33; + } + + int operator== (D, char) + { + return 34; + } +} + +int operator== (D, float) +{ + return 35; +} + +//------------------ + +class E +{ +}; +namespace F +{ + int operator== (E, int) + { + return 44; + } + + int operator== (E, char) + { + return 45; + } +} + +int operator== (E, float) +{ + return 46; +} + +using namespace F; + +//----------------- + +class G +{ +public: + int operator== (int) + { + return 55; + } +}; + +int operator== (G, char) +{ + return 56; +} + +//------------------ + +class H +{ +}; +namespace I +{ + int operator== (H, int) + { + return 66; + } +} + +namespace ALIAS = I; + +//------------------ + +class J +{ +}; + +namespace K +{ + int i; + int operator== (J, int) + { + return 77; + } +} + +using K::i; + +//------------------ + +class L +{ +}; +namespace M +{ + int operator== (L, int) + { + return 88; + } +} + +namespace N +{ + using namespace M; +} + +using namespace N; + +//------------------ + +int main () +{ + A a; + a == 1; + a == 'a'; + + B::C bc; + bc == 1; + bc == 'a'; + B::BD::operator== (bc,'a'); + + D d; + d == 1; + d == 'a'; + d == 1.0f; + + E e; + e == 1; + e == 'a'; + e == 1.0f; + + G g; + g == 1; + g == 'a'; + + H h; + I::operator== (h, 1); + + J j; + K::operator== (j, 1); + + L l; + l == 1; + + return 0; +} |