summaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2005-03-08 14:35:20 +0000
committerNathan Sidwell <nathan@codesourcery.com>2005-03-08 14:35:20 +0000
commitbdfc42ff1d498685109533048732356c8637129b (patch)
tree9234be33284efb08a2d62bb1376d7d76235e121f /gdb/testsuite
parentaa69a4b6504d84ef657bed25bf89e0066b66c33e (diff)
downloadgdb-bdfc42ff1d498685109533048732356c8637129b.tar.gz
* ax-gdb.c (gen_expr): Add UNOP_PLUS case.
* c-exp.y (exp): Add unary plus. * eval.c (evaluate_subexp_standard): Add UNOP_PLUS case. * valarith.c (value_x_unop): Add UNOP_PLUS case. (value_pos): New. * value.h (value_pos): Declare. * gdb.cp/userdef.cc (A1::operator+): New unary plus. (A2): New class. (main): Test operator+. * gdb.cp/userdef.exp: Test unary plus. Use A2::operator+ for breakpoint test.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.cp/userdef.cc23
-rw-r--r--gdb/testsuite/gdb.cp/userdef.exp6
3 files changed, 33 insertions, 2 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ace5929e975..73f01bdb75a 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,11 @@
2005-03-08 Nathan Sidwell <nathan@codesourcery.com>
+ * gdb.cp/userdef.cc (A1::operator+): New unary plus.
+ (A2): New class.
+ (main): Test operator+.
+ * gdb.cp/userdef.exp: Test unary plus. Use A2::operator+ for
+ breakpoint test.
+
* gdb.base/sigbpt.exp: Disable if gdb,nosignals.
* gdb.base/signull.exp: Disable if gdb,nosignals.
* gdb.cp/bs15503.exp: Disable if skip_cplus_tests
diff --git a/gdb/testsuite/gdb.cp/userdef.cc b/gdb/testsuite/gdb.cp/userdef.cc
index a40995a8650..0cf25958809 100644
--- a/gdb/testsuite/gdb.cp/userdef.cc
+++ b/gdb/testsuite/gdb.cp/userdef.cc
@@ -63,6 +63,7 @@ A1 operator/(const A1&);
A1 operator=(const A1&);
A1 operator~();
+A1 operator+();
A1 operator-();
int operator!();
A1 operator++();
@@ -225,6 +226,15 @@ A1 A1::operator-(void)
return (neg);
}
+A1 A1::operator+(void)
+{
+ A1 pos(0,0);
+ pos.x = +x;
+ pos.y = +y;
+
+ return (pos);
+}
+
A1 A1::operator~(void)
{
A1 acompl(0,0);
@@ -286,6 +296,17 @@ ostream& operator<<(ostream& outs, A1 one)
return (outs << endl << "x = " << one.x << endl << "y = " << one.y << endl << "-------" << endl);
}
+class A2 {
+ public:
+A2 operator+();
+};
+
+A2 A2::operator+()
+{
+ return A2 ();
+}
+
+
int main (void)
{
A1 one(2,3);
@@ -342,6 +363,8 @@ int main (void)
val = (!one);
cout << "! " << val << endl << "-----"<<endl;
+ three = (+one);
+ cout << "+ " << three;
three = (-one);
cout << "- " << three;
three = (~one);
diff --git a/gdb/testsuite/gdb.cp/userdef.exp b/gdb/testsuite/gdb.cp/userdef.exp
index 5c9c9338a87..86e901dcd94 100644
--- a/gdb/testsuite/gdb.cp/userdef.exp
+++ b/gdb/testsuite/gdb.cp/userdef.exp
@@ -121,6 +121,8 @@ gdb_test "print one >> 31" "\\\$\[0-9\]* = {x = 0, y = 0}"
gdb_test "print !one" "\\\$\[0-9\]* = 0\[\r\n\]"
# Assumes 2's complement. So does everything...
+gdb_test "print +one" "\\\$\[0-9\]* = {x = 2, y = 3}"
+
gdb_test "print ~one" "\\\$\[0-9\]* = {x = -3, y = -4}"
gdb_test "print -one" "\\\$\[0-9\]* = {x = -2, y = -3}"
@@ -138,8 +140,8 @@ gdb_test "print one += 7" "\\\$\[0-9\]* = {x = 9, y = 10}"
gdb_test "print two = one" "\\\$\[0-9\]* = {x = 9, y = 10}"
# Check that GDB tolerates whitespace in operator names.
-gdb_test "break A1::'operator+'" ".*Breakpoint $decimal at.*"
-gdb_test "break A1::'operator +'" ".*Breakpoint $decimal at.*"
+gdb_test "break A2::'operator+'" ".*Breakpoint $decimal at.*"
+gdb_test "break A2::'operator +'" ".*Breakpoint $decimal at.*"
gdb_exit
return 0