Update copyright year range in all GDB files
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / classes.cc
index 7d69ed225ae523c7c1586632231c25edbdc93751..960b31be06c862fbad9a10ee3cc979f61aba49d1 100644 (file)
@@ -1,22 +1,19 @@
 /* This testcase is part of GDB, the GNU debugger.
 
-   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
-   Free Software Foundation, Inc.
+   Copyright 1993-2018 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
+
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-   */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 // Test various -*- C++ -*- things.
 
@@ -401,8 +398,11 @@ class Base1 {
  public:
   int x;
   Base1(int i) { x = i; }
+  ~Base1 () { }
 };
 
+typedef Base1 base1;
+
 class Foo
 {
  public:
@@ -415,6 +415,8 @@ class Foo
   int times (int y);
 };
 
+typedef Foo ByAnyOtherName;
+
 class Bar : public Base1, public Foo {
  public:
   int z;
@@ -429,9 +431,27 @@ int Foo::st = 100;
 
 Foo::operator int() { return x; }
 
-Foo foo(10, 11);
+ByAnyOtherName foo(10, 11);
 Bar bar(20, 21, 22);
 
+/* Use a typedef for the baseclass to exercise gnu-v3-abi.c:gnuv3_dynamic_class
+   recursion.  It's important that the class itself have no name to make sure
+   the typedef makes it through to the recursive call.  */
+typedef class {
+ public:
+  int x;
+  virtual int get_x () { return x; }
+} DynamicBase2;
+
+class DynamicBar : public DynamicBase2
+{
+ public:
+  DynamicBar (int i, int j) { x = i; y = j; }
+  int y;
+};
+
+DynamicBar dynbar (23, 24);
+
 class ClassWithEnum {
 public:
   enum PrivEnum { red, green, blue, yellow = 42 };
@@ -453,6 +473,7 @@ void enums1 ()
   obj_with_enum.x = 0;
   enums2 ();
   obj_with_enum.priv_enum = ClassWithEnum::green;
+  obj_with_enum.x = 1;
 }
 
 class ClassParam {
@@ -524,6 +545,82 @@ small::method ()
   return x + 5;
 }
 
+class class_with_typedefs
+{
+public:
+  typedef int public_int;
+protected:
+  typedef int protected_int;
+private:
+  typedef int private_int;
+
+public:
+  class_with_typedefs ()
+    : public_int_ (1), protected_int_ (2), private_int_ (3) {}
+  public_int add_public (public_int a) { return a + public_int_; }
+  public_int add_all (int a)
+  { return add_public (a) + add_protected (a) + add_private (a); }
+
+protected:
+  protected_int add_protected (protected_int a) { return a + protected_int_; }
+
+private:
+  private_int add_private (private_int a) { return a + private_int_; }
+
+protected:
+  public_int public_int_;
+  protected_int protected_int_;
+  private_int private_int_;
+};
+
+class class_with_public_typedef
+{
+  int a;
+public:
+  typedef int INT;
+  INT b;
+};
+
+class class_with_protected_typedef
+{
+  int a;
+protected:
+  typedef int INT;
+  INT b;
+};
+
+class class_with_private_typedef
+{
+  int a;
+private:
+  typedef int INT;
+  INT b;
+};
+
+struct struct_with_public_typedef
+{
+  int a;
+public:
+  typedef int INT;
+  INT b;
+};
+
+struct struct_with_protected_typedef
+{
+  int a;
+protected:
+  typedef int INT;
+  INT b;
+};
+
+struct struct_with_private_typedef
+{
+  int a;
+private:
+  typedef int INT;
+  INT b;
+};
+
 void marker_reg1 () {}
 
 int
@@ -564,16 +661,27 @@ void use_methods ()
   i = class_param.Aref_x (g_A);
   i = class_param.Aval_a (g_A);
   i = class_param.Aval_x (g_A);
+
+  base1 b (3);
 }
 
+struct Inner
+{
+  static Inner instance;
+};
+
+struct Outer
+{
+  Inner inner;
+  static Outer instance;
+};
+
+Inner Inner::instance;
+Outer Outer::instance;
 
 int
 main()
 {
-#ifdef usestubs
-  set_debug_traps();
-  breakpoint();
-#endif
   dummy();
   inheritance1 ();
   inheritance3 ();
@@ -605,3 +713,10 @@ protected_class protected_c;
 default_private_class default_private_c;
 explicit_private_class explicit_private_c;
 mixed_protection_class mixed_protection_c;
+class_with_typedefs class_with_typedefs_c;
+class_with_public_typedef class_with_public_typedef_c;
+class_with_protected_typedef class_with_protected_typedef_c;
+class_with_private_typedef class_with_private_typedef_c;
+struct_with_public_typedef struct_with_public_typedef_s;
+struct_with_protected_typedef struct_with_protected_typedef_s;
+struct_with_private_typedef struct_with_private_typedef_s;
This page took 0.027058 seconds and 4 git commands to generate.