summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.law/visibility7.C
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.old-deja/g++.law/visibility7.C
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.law/visibility7.C')
-rw-r--r--gcc/testsuite/g++.old-deja/g++.law/visibility7.C73
1 files changed, 73 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility7.C b/gcc/testsuite/g++.old-deja/g++.law/visibility7.C
new file mode 100644
index 000000000..ed37f5f8d
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.law/visibility7.C
@@ -0,0 +1,73 @@
+// { dg-do assemble }
+// GROUPS passed visibility
+// visibility file
+// From: Gordon Joly <G.Joly@cs.ucl.ac.uk>
+// Date: Wed, 21 Apr 93 09:42:07 +0100
+// Subject: /*** BUG REPORT : THE MYTH OF PRIVATE INHERITANCE ***/
+// Message-ID: <9304210842.AA01815@life.ai.mit.edu>
+#include <iostream>
+
+class A {
+ private:
+ int number;
+ public:
+ A(int i) : number(i)
+ {}
+ virtual ~A()
+ {}
+ virtual void Number(int c) // { dg-error "inaccessible" }
+ { number = c; }
+ virtual int Number() // { dg-error "inaccessible" }
+ { return number; }
+};
+
+class B : private A {
+ private:
+ int second_number;
+ public:
+ B(int c, int i) : second_number(c), A(i)
+ {}
+ virtual ~B()
+ {}
+
+ virtual void firstNumber(int b) // renames member function Number(int) of class A
+ { A::Number(b); }
+ virtual int firstNumber() // renames member function Number() of class A
+ { return A::Number(); }
+};
+
+
+
+
+class C {
+ private:
+ B* bobject;
+ public:
+ C(B* bp) : bobject(bp)
+ {}
+ virtual ~C()
+ {}
+ //
+ // the following two functions access
+ // private member functions of class B
+ // and they should not be able to do so
+ //
+ virtual void setBValue(int i)
+ { if (bobject) bobject->Number(i); } // { dg-error "this context|accessible base" }
+ virtual int getBValue()
+ { if (bobject) { return bobject->Number(); } return 0; } // { dg-error "this context|accessible base" }
+};
+
+
+int main()
+{
+ B* bobject = new B(2, 1);
+ C* cobject = new C(bobject);
+ cobject->setBValue(8);
+ std::cout << cobject->getBValue() << std::endl;
+ delete bobject;
+ delete cobject;
+}
+
+
+