summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.mike/p658.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++.mike/p658.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++.mike/p658.C')
-rw-r--r--gcc/testsuite/g++.old-deja/g++.mike/p658.C109
1 files changed, 109 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p658.C b/gcc/testsuite/g++.old-deja/g++.mike/p658.C
new file mode 100644
index 000000000..8fc7cd51b
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.mike/p658.C
@@ -0,0 +1,109 @@
+// { dg-do run }
+// prms-id: 658
+
+#include <iostream>
+#include <cstdlib>
+
+/* We may not find the libg++ <bool.h>. */
+#ifndef FALSE
+#define FALSE false
+#endif
+#ifndef TRUE
+#define TRUE true
+#endif
+
+// The VxWorks kernel-mode headers define a macro named "OK", which is not
+// ISO-compliant, but is part of the VxWorks API.
+#if defined __vxworks && !defined __RTP__
+#undef OK
+#endif
+
+class Object {
+public:
+ Object();
+ Object(const Object&);
+ ~Object();
+
+ void OK() const;
+private:
+ bool _destructed;
+};
+
+class Char: public Object {
+public:
+ Char();
+ Char(char);
+ Char(const Char&);
+ ~Char();
+
+ operator char () const;
+private:
+ char _c;
+};
+
+int main()
+{
+ Char r, s;
+
+ r = Char('r');
+ s = Char('s');
+}
+
+//
+// Object stuff
+//
+Object::Object():
+_destructed(FALSE)
+{}
+
+Object::Object(const Object& other):
+_destructed(FALSE)
+{
+ other.OK();
+}
+
+Object::~Object()
+{
+ OK();
+ _destructed = TRUE;
+}
+
+void
+Object::OK() const
+{
+ if (_destructed) {
+ std::cerr << "FAILURE - reference was made to a destructed object\n";
+ std::abort();
+ }
+}
+
+//
+// Char stuff
+//
+
+Char::Char():
+Object(),
+_c('a')
+{ }
+
+Char::Char(char c):
+Object(),
+_c(c)
+{ }
+
+Char::Char(const Char& other):
+Object(other),
+_c(other._c)
+{ }
+
+Char::~Char()
+{
+ OK();
+}
+
+Char::operator char () const
+{
+ return _c;
+}
+
+