Blob Blame History Raw
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jeff Johnston <jjohnstn@redhat.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-6.3-inheritancetest-20050726.patch

;; Verify printing of inherited members test
;;=fedoratest

2005-07-26  Jeff Johnston  <jjohnstn@redhat.com>

	* gdb.cp/b146835.exp: New testcase.
	* gdb.cp/b146835.cc: Ditto.
	* gdb.cp/b146835b.cc: Ditto.
	* gdb.cp/b146835.h: Ditto.

diff --git a/gdb/testsuite/gdb.cp/b146835.cc b/gdb/testsuite/gdb.cp/b146835.cc
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/b146835.cc
@@ -0,0 +1,32 @@
+#include "b146835.h"
+#include <iostream>
+
+class F : public C {
+
+protected:
+
+   virtual void funcA (unsigned long a, B *b);
+   virtual void funcB (E *e);
+   virtual void funcC (unsigned long x, bool y);
+
+   char *s1, *s2;
+   bool b1;
+   int k;
+
+public:
+   void foo() {
+       std::cout << "foo" << std::endl;
+   }
+};
+
+
+void F::funcA (unsigned long a, B *b) {}
+void F::funcB (E *e) {}
+void F::funcC (unsigned long x, bool y) {}
+
+int  main()
+{
+   F f;
+   f.foo();
+}
+
diff --git a/gdb/testsuite/gdb.cp/b146835.exp b/gdb/testsuite/gdb.cp/b146835.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/b146835.exp
@@ -0,0 +1,47 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2005 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
+# (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.  
+
+# Check that GDB can properly print an inherited member variable
+# (Bugzilla 146835)
+
+set testfile "b146835"
+set srcfile ${testfile}.cc
+set srcfile2 ${testfile}b.cc
+set binfile [standard_output_file ${testfile}]
+if {[gdb_compile "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile2}" "${binfile}" executable {debug c++}] != "" } {
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+#
+# Run to `main' where we begin our tests.
+#
+
+if ![runto_main] then {
+    gdb_suppress_tests
+}
+
+gdb_test "break 'F::foo()'" ""
+gdb_continue_to_breakpoint "First line foo"
+
+# Verify that we can access the inherited member d
+gdb_test "p d" " = \\(D \\*\\) *0x0" "Verify inherited member d accessible"
diff --git a/gdb/testsuite/gdb.cp/b146835.h b/gdb/testsuite/gdb.cp/b146835.h
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/b146835.h
@@ -0,0 +1,36 @@
+
+class A {
+
+protected:
+
+   virtual void funcA (unsigned long a, class B *b) = 0;
+   virtual void funcB (class E *e) = 0;
+   virtual void funcC (unsigned long x, bool y) = 0;
+
+   void funcD (class E *e, class D* d);
+   virtual void funcE (E *e, D *d);
+   virtual void funcF (unsigned long x, D *d);
+};
+
+
+class C : public A {
+
+protected:
+
+   int x;
+   class K *k;
+   class H *h;
+
+   D *d;
+
+   class W *w;
+   class N *n;
+   class L *l;
+   unsigned long *r;
+
+public:
+
+   C();
+   int z (char *s);
+   virtual ~C();
+};
diff --git a/gdb/testsuite/gdb.cp/b146835b.cc b/gdb/testsuite/gdb.cp/b146835b.cc
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/b146835b.cc
@@ -0,0 +1,11 @@
+#include "b146835.h"
+
+C::C() { d = 0; x = 3; }
+
+int C::z (char *s) { return 0; }
+
+C::~C() {}
+
+void A::funcD (class E *e, class D *d) {}
+void A::funcE (E *e, D *d) {}
+void A::funcF (unsigned long x, D *d) {}