summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.c++/misc.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.c++/misc.cc')
-rw-r--r--gdb/testsuite/gdb.c++/misc.cc59
1 files changed, 48 insertions, 11 deletions
diff --git a/gdb/testsuite/gdb.c++/misc.cc b/gdb/testsuite/gdb.c++/misc.cc
index 3090800c7d6..caa54511838 100644
--- a/gdb/testsuite/gdb.c++/misc.cc
+++ b/gdb/testsuite/gdb.c++/misc.cc
@@ -393,6 +393,17 @@ class Bar : public Base1, public Foo {
Bar (int i, int j, int k) : Base1 (10*k), Foo (i, j) { z = k; }
};
+int Foo::operator! () { return !x; }
+
+int Foo::times (int y) { return x * y; }
+
+int Foo::st = 100;
+
+Foo::operator int() { return x; }
+
+Foo foo(10, 11);
+Bar bar(20, 21, 22);
+
class ClassWithEnum {
public:
enum PrivEnum { red, green, blue, yellow = 42 };
@@ -400,16 +411,33 @@ public:
int x;
};
-int Foo::operator! () { return !x; }
+void enums2 (void)
+{
+}
-int Foo::times (int y) { return x * y; }
+/* classes.exp relies on statement order in this function for testing
+ enumeration fields. */
-int Foo::st = 100;
+void enums1 ()
+{
+ ClassWithEnum obj_with_enum;
+ obj_with_enum.priv_enum = ClassWithEnum::red;
+ obj_with_enum.x = 0;
+ enums2 ();
+ obj_with_enum.priv_enum = ClassWithEnum::green;
+}
-Foo::operator int() { return x; }
+class ClassParam {
+public:
+ int Aptr_a (A *a) { return a->a; }
+ int Aptr_x (A *a) { return a->x; }
+ int Aref_a (A &a) { return a.a; }
+ int Aref_x (A &a) { return a.x; }
+ int Aval_a (A a) { return a.a; }
+ int Aval_x (A a) { return a.x; }
+};
-Foo foo(10, 11);
-Bar bar(20, 21, 22);
+ClassParam class_param;
class Contains_static_instance
{
@@ -498,6 +526,18 @@ void dummy()
v_bool_array[1] = v_bool;
}
+void use_methods ()
+{
+ /* Refer to methods so that they don't get optimized away. */
+ int i;
+ i = class_param.Aptr_a (&g_A);
+ i = class_param.Aptr_x (&g_A);
+ i = class_param.Aref_a (g_A);
+ i = class_param.Aref_x (g_A);
+ i = class_param.Aval_a (g_A);
+ i = class_param.Aval_x (g_A);
+}
+
int
main()
@@ -509,6 +549,7 @@ main()
dummy();
inheritance1 ();
inheritance3 ();
+ enums1 ();
register_class ();
/* FIXME: pmi gets optimized out. Need to do some more computation with
@@ -519,11 +560,7 @@ main()
/* Make sure the AIX linker doesn't remove the variable. */
v_tagless.one = 5;
- /* Class with enumeration inside it */
- ClassWithEnum obj_with_enum;
- obj_with_enum.priv_enum = ClassWithEnum::red;
- obj_with_enum.x = 0;
- obj_with_enum.priv_enum = ClassWithEnum::green;
+ use_methods ();
return foo.*pmi;
}