aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libvtv/testsuite/libvtv.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/libvtv/testsuite/libvtv.cc')
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/bb_tests.cc53
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/const_vtable.cc83
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/dataentry.cc39
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/derived-lib.cpp18
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/derived-main.cpp18
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/derived.list1
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/dup_name.cc62
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/environment.cc38
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/event-defintions.cpp10
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/event-main.cpp15
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/event-private.cpp10
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/event-private.h7
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/event.h29
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/event.list1
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/mul_inh.cc27
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/nested_vcall_test.cc77
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.cpp16
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.h14
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts.cpp15
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts.h13
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-main.cpp39
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-main.h15
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test.list1
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/povray-derived.cc74
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/register_set_pair.cc101
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/register_set_pair_inserts.cc106
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/template-list-iostream.cc120
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/template-list.cc94
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/template-list2.cc46
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/test1.cc74
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/thunk.cc37
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/thunk_vtable_map_attack.cc113
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/v8-test-2.cc97
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/virtfunc-test.cc222
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/virtual_inheritance.cc48
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/vtv.exp83
-rw-r--r--gcc-4.9/libvtv/testsuite/libvtv.cc/xlan-test.cc185
37 files changed, 2001 insertions, 0 deletions
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/bb_tests.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/bb_tests.cc
new file mode 100644
index 000000000..2a2447d02
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/bb_tests.cc
@@ -0,0 +1,53 @@
+// { dg-do run }
+struct base
+{
+ int total;
+ virtual void add (int i) { total += i; }
+ virtual void sub (int i) { total -= i; }
+ virtual void init (void) { total = 73; }
+};
+
+struct derived : public base
+{
+ int total;
+ virtual void add (int i) { total += 10 * i; }
+ virtual void sub (int i) { total -= 2 * i; }
+ virtual void init (void) { total = 0; }
+};
+
+bool
+get_cond_value (int x)
+{
+ if ((x % 3) > 0)
+ return true;
+ else
+ return false;
+
+ return false;
+}
+
+int
+main (int argc, char **argv)
+{
+ base *a;
+ bool cond_value = get_cond_value (10);
+ int x;
+
+ if (cond_value)
+ a = new base ();
+ else
+ a = new derived ();
+
+ cond_value = get_cond_value (47);
+ x = 0;
+ if (!cond_value)
+ x = 17;
+
+ a->init ();
+
+ for ( ; x < 10; ++x)
+ {
+ a->add(50);
+ a->sub(25);
+ }
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/const_vtable.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/const_vtable.cc
new file mode 100644
index 000000000..3229f0083
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/const_vtable.cc
@@ -0,0 +1,83 @@
+// { dg-do run }
+extern "C" int printf(const char *,...);
+struct V1 {
+ int v;
+ virtual int foo();
+ V1();
+ ~V1();
+};
+struct V2 : virtual V1 {
+ int v2;
+ virtual int foo();
+ V2();
+ ~V2();
+};
+struct C : virtual V1, virtual V2 {
+ int c;
+ virtual int foo();
+ C();
+ ~C();
+};
+
+struct B {
+ int b; };
+struct D : B, C {
+ int d;
+ virtual int bar();
+ D();
+ ~D();
+};
+extern "C" int printf(const char *,...);
+main()
+{
+ try {
+ D *d = new D;
+ delete d;
+ } catch (int) {
+ printf("Int caught\n");
+ }
+}
+
+int V1::foo() {
+ printf("V1::foo called\n"); return 1; }
+V1::V1() : v(5) {
+ printf("V1 called\n"); }
+V1::~V1() {
+ printf("~V1 called\n"); }
+
+int V2::foo() {
+ printf("V2::foo called\n"); return 1; }
+V2::V2() : v2(6) {
+ printf("V2 called\n"); }
+V2::~V2() {
+ printf("~V2 called\n"); }
+
+int C::foo() {
+ printf("C::foo called %d\n", c); return 1; }
+C::C() : c(7) {
+ printf("C called\n");
+ V1 *vv = this; vv->foo();
+ C *cp = dynamic_cast<C *>(vv);
+ if (this == cp) {
+ printf("PASSED this == cp\n");
+ } else {
+ printf("FAILED this != cp\n");
+ }
+}
+C::~C() {
+ printf("~C called\n");
+ V1 *vv = this; vv->foo();
+ C *cp = dynamic_cast<C *>(vv);
+ if (this == cp) {
+ printf("PASSED this == cp\n");
+ } else {
+ printf("FAILED this != cp\n");
+ }
+}
+
+int D::bar() {
+ printf("D::bar called\n"); return 1; }
+D::D() : d(8) {
+ printf("D called\n"); throw 5; }
+D::~D() {
+ printf("~D called\n"); }
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/dataentry.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/dataentry.cc
new file mode 100644
index 000000000..6246136e5
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/dataentry.cc
@@ -0,0 +1,39 @@
+// { dg-do run }
+
+template<int patch_dim, int patch_space_dim>
+class DataOutInterface
+{
+ public:
+ virtual ~DataOutInterface() {}
+};
+
+template <int dof_handler_dim, int patch_dim, int patch_space_dim=patch_dim>
+class DataOut_DoFData : public DataOutInterface<patch_dim,patch_space_dim>
+{
+ public:
+ virtual ~DataOut_DoFData() {}
+
+class DataEntryBase {
+ public:
+ virtual ~DataEntryBase () {}
+};
+
+template <typename T>
+class DataEntry : public DataEntryBase
+{
+ public:
+ virtual ~DataEntry() {}
+};
+};
+
+template <typename T> void Destroy(T * p) __attribute__((noinline));
+template <typename T> void Destroy(T * p)
+{
+ delete p;
+}
+
+int main()
+{
+ DataOut_DoFData<3,3>::DataEntryBase * p = new DataOut_DoFData<3,3>::DataEntry<int>();
+ Destroy(p);
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/derived-lib.cpp b/gcc-4.9/libvtv/testsuite/libvtv.cc/derived-lib.cpp
new file mode 100644
index 000000000..375dbe41b
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/derived-lib.cpp
@@ -0,0 +1,18 @@
+#include "lib.h"
+
+struct Derived_Private : public Base
+{
+ virtual ~Derived_Private()
+ { printf("in Derived_Private destructor\n"); }
+};
+
+Base * GetPrivate()
+{
+ return new Derived_Private();
+}
+
+void Destroy(Base * pb)
+{
+ delete pb; // Virtual call #1
+}
+
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/derived-main.cpp b/gcc-4.9/libvtv/testsuite/libvtv.cc/derived-main.cpp
new file mode 100644
index 000000000..0933ff696
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/derived-main.cpp
@@ -0,0 +1,18 @@
+// { dg-do run }
+
+#include "lib.h"
+
+struct Derived: public Base
+{
+ virtual ~Derived()
+ { printf("In Derived destructor\n"); }
+};
+
+int main()
+{
+ Derived * d = new Derived;
+ Destroy(d);
+ Base * pp = GetPrivate();
+ delete pp; // Virtual call #2
+}
+
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/derived.list b/gcc-4.9/libvtv/testsuite/libvtv.cc/derived.list
new file mode 100644
index 000000000..6ea3b9cf6
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/derived.list
@@ -0,0 +1 @@
+derived-main.cpp derived-lib.cpp
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/dup_name.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/dup_name.cc
new file mode 100644
index 000000000..d9d025126
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/dup_name.cc
@@ -0,0 +1,62 @@
+// { dg-do run }
+
+#include <assert.h>
+
+extern "C" int printf(const char *, ...);
+
+class Subscriptor
+{
+ public:
+
+ Subscriptor()
+ { counter = 1;}
+
+ virtual ~Subscriptor()
+ {
+ counter--;
+ assert(counter == 0);
+ }
+
+ private:
+ static int counter;
+};
+
+int Subscriptor::counter;
+
+template <typename number>
+class Polynomial : public Subscriptor
+{
+};
+
+class LagrangeEquidistant: public Polynomial<double>
+{
+};
+
+template <int value>
+class A
+{
+ public:
+ class Nested: public LagrangeEquidistant
+ {
+ };
+ A() { n = new Nested; }
+ ~A() { delete n; }
+ Subscriptor * n;
+};
+
+template<typename _Tp>
+inline void
+_MyDestroy(_Tp* __pointer)
+ { __pointer->~_Tp(); }
+
+int main()
+{
+ Subscriptor * s1 = new LagrangeEquidistant;
+ _MyDestroy(s1);
+ A<1> * a1 = new A<1>;
+ _MyDestroy(a1);
+ A<2> * a2 = new A<2>;
+ _MyDestroy(a2);
+
+ return 0;
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/environment.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/environment.cc
new file mode 100644
index 000000000..af1a87752
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/environment.cc
@@ -0,0 +1,38 @@
+// { dg-do run }
+
+extern "C" int printf(const char *, ...);
+
+class Environment {
+ public:
+ virtual ~Environment();
+
+ // Static factory method that returns the implementation that provide the
+ // appropriate platform-specific instance.
+ static Environment* Create();
+
+ // Gets an environment variable's value and stores it in |result|.
+ // Returns false if the key is unset.
+ virtual bool GetVar(const char* variable_name, char* result) = 0;
+};
+
+class EnvironmentImpl : public Environment {
+ public:
+ virtual bool GetVar(const char* variable_name, char* result) {
+ return true;
+ }
+};
+
+Environment::~Environment() {}
+
+// static
+Environment* Environment::Create() {
+ return new EnvironmentImpl();
+}
+
+int main()
+{
+ char * null = 0;
+ Environment * env = Environment::Create();
+ env->GetVar(0, null);
+ printf("%p\n", env);
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/event-defintions.cpp b/gcc-4.9/libvtv/testsuite/libvtv.cc/event-defintions.cpp
new file mode 100644
index 000000000..ba9efe11a
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/event-defintions.cpp
@@ -0,0 +1,10 @@
+#include "event.h"
+
+Event::Event()
+{
+}
+
+Event::~Event()
+{
+
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/event-main.cpp b/gcc-4.9/libvtv/testsuite/libvtv.cc/event-main.cpp
new file mode 100644
index 000000000..95c464031
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/event-main.cpp
@@ -0,0 +1,15 @@
+// { dg-do run }
+
+#include "event-private.h"
+
+template<typename T> void derefIfNotNull(T* ptr)
+{
+ if (ptr != 0)
+ ptr->deref();
+}
+
+int main()
+{
+ Event * ev = new Event;
+ derefIfNotNull(ev);
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/event-private.cpp b/gcc-4.9/libvtv/testsuite/libvtv.cc/event-private.cpp
new file mode 100644
index 000000000..a27f4697a
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/event-private.cpp
@@ -0,0 +1,10 @@
+#include "event-private.h"
+
+PrivateEvent::PrivateEvent()
+{
+}
+
+PrivateEvent::~PrivateEvent()
+{
+
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/event-private.h b/gcc-4.9/libvtv/testsuite/libvtv.cc/event-private.h
new file mode 100644
index 000000000..678ab5f68
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/event-private.h
@@ -0,0 +1,7 @@
+#include "event.h"
+
+class PrivateEvent: public Event {
+ public:
+ PrivateEvent();
+ ~PrivateEvent ();
+};
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/event.h b/gcc-4.9/libvtv/testsuite/libvtv.cc/event.h
new file mode 100644
index 000000000..61e1d7c91
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/event.h
@@ -0,0 +1,29 @@
+class RefCountedBase {
+protected:
+ bool derefBase()
+ {
+ return true;
+ }
+};
+
+template<typename T> class RefCounted : public RefCountedBase {
+public:
+ void deref()
+ {
+ if (derefBase())
+ delete static_cast<T*>(this);
+ }
+
+protected:
+ // RefCounted() { }
+ ~RefCounted()
+ {
+ }
+};
+
+
+class Event : public RefCounted<Event> {
+ public:
+ Event();
+ virtual ~Event();
+};
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/event.list b/gcc-4.9/libvtv/testsuite/libvtv.cc/event.list
new file mode 100644
index 000000000..77606f8c1
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/event.list
@@ -0,0 +1 @@
+event-main.cpp event-definitions.cpp event-private.cpp \ No newline at end of file
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/mul_inh.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/mul_inh.cc
new file mode 100644
index 000000000..b32b710c8
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/mul_inh.cc
@@ -0,0 +1,27 @@
+// { dg-do run }
+
+extern "C" int printf(const char *, ...);
+
+struct A {
+ virtual ~A() {}
+};
+
+struct B {
+ virtual ~B() {}
+};
+
+struct C: public A {
+ virtual ~C() {}
+};
+
+struct D: public C, B {
+ virtual ~D() {}
+};
+
+D d;
+
+int main()
+{
+ printf ("%p\n", &d);
+ return 0;
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/nested_vcall_test.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/nested_vcall_test.cc
new file mode 100644
index 000000000..9d1a9c692
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/nested_vcall_test.cc
@@ -0,0 +1,77 @@
+// { dg-do run }
+
+class EtherCtrl {
+ protected:
+ int ssap;
+
+ public:
+ EtherCtrl(void);
+ ~EtherCtrl();
+ virtual int getSsap(void) const;
+ virtual void setSsap(int);
+};
+
+class EtherFrameWithLLC {
+ protected:
+ int ssap;
+
+ public:
+ EtherFrameWithLLC(const char *, int);
+ ~EtherFrameWithLLC();
+ virtual int getSsap(void) const;
+ virtual void setSsap(int);
+};
+
+
+EtherCtrl::EtherCtrl()
+{
+ this->ssap = 0;
+}
+
+EtherCtrl::~EtherCtrl()
+{
+}
+
+int EtherCtrl::getSsap() const
+{
+ return ssap;
+}
+
+void EtherCtrl::setSsap(int ssap)
+{
+ this->ssap = ssap;
+}
+
+EtherFrameWithLLC::EtherFrameWithLLC(const char *name, int kind)
+{
+ this->ssap = 0;
+}
+
+EtherFrameWithLLC::~EtherFrameWithLLC()
+{
+}
+
+int EtherFrameWithLLC::getSsap() const
+{
+ return ssap;
+}
+
+void EtherFrameWithLLC::setSsap(int ssap)
+{
+ this->ssap = ssap;
+}
+
+
+int
+main (int argc, char **argv)
+{
+ EtherCtrl *etherctrl = new EtherCtrl ();
+ EtherFrameWithLLC *frame = new EtherFrameWithLLC ("test", 10);
+ int my_value;
+
+ etherctrl->setSsap(43);
+ frame->setSsap(etherctrl->getSsap());
+ my_value = frame->getSsap();
+
+ return 0;
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.cpp b/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.cpp
new file mode 100644
index 000000000..13d7fdc6e
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.cpp
@@ -0,0 +1,16 @@
+#include "parts-test-extra-parts-views.h"
+
+ExtraPartsViews::ExtraPartsViews ()
+ : ExtraParts () {
+}
+
+ExtraPartsViews::~ExtraPartsViews () {}
+
+void
+ExtraPartsViews::ToolkitInitialized ()
+{
+ /* Do something */
+ int sum = 0;
+ for (int i = 0; i < 10; ++i)
+ sum += i;
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.h b/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.h
new file mode 100644
index 000000000..0784c0ecd
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.h
@@ -0,0 +1,14 @@
+#ifndef _EXTRA_PARTS_VIEWS_H_
+#define _EXTRA_PARTS_VIEWS_H_
+
+#include "parts-test-extra-parts.h"
+
+class ExtraPartsViews : public ExtraParts {
+ public:
+ ExtraPartsViews ();
+ virtual ~ExtraPartsViews ();
+
+ virtual void ToolkitInitialized ();
+};
+
+#endif /* _EXTRA_PARTS_VIEWS_H_ */
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts.cpp b/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts.cpp
new file mode 100644
index 000000000..dbd3dbfd8
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts.cpp
@@ -0,0 +1,15 @@
+#include "parts-test-extra-parts.h"
+
+ExtraParts::ExtraParts () {}
+
+ExtraParts::~ExtraParts () {}
+
+void
+ExtraParts::ToolkitInitialized ()
+{
+}
+
+void
+ExtraParts::PreEarlyInitialization ()
+{
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts.h b/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts.h
new file mode 100644
index 000000000..4ed2a4ce1
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-extra-parts.h
@@ -0,0 +1,13 @@
+#ifndef _EXTRA_PARTS_H_
+#define _EXTRA_PARTS_H_
+
+class ExtraParts {
+ public:
+ ExtraParts ();
+ virtual ~ExtraParts ();
+
+ virtual void PreEarlyInitialization ();
+ virtual void ToolkitInitialized ();
+};
+
+#endif /* _EXTRA_PARTS_H_ */
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-main.cpp b/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-main.cpp
new file mode 100644
index 000000000..a0cc721ab
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-main.cpp
@@ -0,0 +1,39 @@
+// { dg-do run }
+
+#include "parts-test-main.h"
+#include "parts-test-extra-parts-views.h"
+
+MainParts::MainParts () {}
+
+MainParts::~MainParts ()
+{
+ for (int i = static_cast<int>(main_extra_parts_.size()) - 1; i >= 0; --i)
+ delete main_extra_parts_[i];
+ main_extra_parts_.clear();
+}
+
+void
+MainParts::AddParts (ExtraParts *parts)
+{
+ main_extra_parts_.push_back (parts);
+}
+
+
+void
+MainParts::PreEarlyInitialization (void)
+{
+ for (int i = 0; i < main_extra_parts_.size(); ++i)
+ main_extra_parts_[i]->PreEarlyInitialization ();
+}
+
+
+int
+main (int argc, char **argv)
+{
+ MainParts *main_parts = new MainParts ();
+
+ main_parts->AddParts (new ExtraPartsViews ());
+ main_parts->PreEarlyInitialization ();
+
+ return 0;
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-main.h b/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-main.h
new file mode 100644
index 000000000..fb631dec3
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test-main.h
@@ -0,0 +1,15 @@
+#include <vector>
+
+class ExtraParts;
+
+class MainParts {
+ public:
+ MainParts ();
+ virtual ~MainParts ();
+ virtual void AddParts (ExtraParts *parts);
+
+ virtual void PreEarlyInitialization ();
+
+ protected:
+ std::vector<ExtraParts *> main_extra_parts_;
+};
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test.list b/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test.list
new file mode 100644
index 000000000..11a959a62
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/parts-test.list
@@ -0,0 +1 @@
+parts-test-main.cpp parts-test-extra-parts.cpp parts-test-extra-parts-views.cpp
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/povray-derived.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/povray-derived.cc
new file mode 100644
index 000000000..9005826df
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/povray-derived.cc
@@ -0,0 +1,74 @@
+// { dg-do run }
+
+// Small test case from povray, see if it reproduces.
+
+#include <stdio.h>
+
+class POVMS_MessageReceiver
+{
+
+private:
+ int x;
+ class Handler
+ {
+ public:
+ virtual void print() = 0;
+ };
+protected:
+ template<class T> class MemberHandler : public Handler
+ {
+ public:
+ MemberHandler(T *xx)
+ {
+ x = xx;
+ }
+
+ ~MemberHandler() {}
+
+ void print()
+ {
+ printf("In print\n");
+ }
+ private:
+ T *x;
+ };
+
+private:
+ struct HandlerNode
+ {
+ Handler *handler;
+ };
+
+ HandlerNode *receiver;
+public:
+ POVMS_MessageReceiver(int xx) : x(xx) {}
+ ~POVMS_MessageReceiver() {}
+
+ void foo(int *xx);
+ void try_call();
+};
+
+void POVMS_MessageReceiver::foo(int *xx)
+{
+ receiver = new HandlerNode;
+
+ receiver->handler = new MemberHandler<int>(xx);
+}
+
+void POVMS_MessageReceiver::try_call()
+{
+ receiver->handler->print();
+}
+
+
+int main()
+{
+ int loc = 34;
+ POVMS_MessageReceiver a_test(100);
+
+ a_test.foo(&loc);
+ a_test.try_call();
+}
+
+
+
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/register_set_pair.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/register_set_pair.cc
new file mode 100644
index 000000000..b7f08331d
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/register_set_pair.cc
@@ -0,0 +1,101 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "vtv_utils.h"
+#include "vtv_rts.h"
+
+/* This configuration will test mostly inserting of elements that are already inserted since
+ the number of repeats is 200 */
+
+#define NUM_MAPS 4000
+#define ELEMENTS_PER_MAP 100
+#define NUM_REPEATS 200
+
+#define KEY_TYPE_FIXED_SIZE 8
+void *key_buffer = malloc (17);
+typedef char * name_string;
+name_string fake_names[NUM_MAPS];
+
+/* This variable has to be put in rel.ro */
+void * maps[NUM_MAPS] VTV_PROTECTED_VAR;
+
+struct fake_vt {
+ void * fake_vfp [4];
+};
+void * fake_vts [NUM_MAPS * ELEMENTS_PER_MAP];
+
+void
+generate_names (void)
+{
+ int i;
+
+ for (i = 0; i < NUM_MAPS; ++i)
+ {
+ fake_names[i] = (char *) malloc (9 * sizeof (char));
+ snprintf (fake_names[i], 9, "name%d", i);
+ }
+}
+
+static uint32_t
+vtv_string_hash(const char *in)
+{
+ const char *s = in;
+ uint32_t h = 0;
+
+ for ( ; *s; ++s)
+ h = 5 * h + *s;
+ return h;
+}
+
+int main()
+{
+ __VLTChangePermission(__VLTP_READ_WRITE);
+
+ generate_names ();
+
+ for (int k = 0; k < NUM_REPEATS; k++)
+ {
+ int curr_fake_vt = 0;
+ for (int i = 0; i < NUM_MAPS; i++)
+ {
+ uint32_t *value_ptr = (uint32_t *) key_buffer;
+ uint32_t len1 = strlen (fake_names[i]);
+ uint32_t hash_value = vtv_string_hash (fake_names[i]);
+ void *temp_array[ELEMENTS_PER_MAP];
+
+ *value_ptr = len1;
+ value_ptr++;
+ *value_ptr = hash_value;
+
+ memcpy ((char *) key_buffer + KEY_TYPE_FIXED_SIZE, fake_names[i],
+ len1);
+
+
+#ifdef VTV_DEBUG
+ __VLTRegisterPairDebug (&maps[i], (char *) key_buffer, 128,
+ &fake_vts[curr_fake_vt], "", "");
+#else
+ __VLTRegisterPair (&maps[i], (char *) key_buffer, 128,
+ &fake_vts[curr_fake_vt]);
+#endif
+ for (int j = 0; j < ELEMENTS_PER_MAP; j++)
+ {
+ temp_array[j] = &fake_vts[curr_fake_vt];
+ curr_fake_vt++;
+ }
+#ifdef VTV_DEBUG
+ __VLTRegisterSetDebug (&maps[i], (char *) key_buffer, 128, 100,
+ (void **) &temp_array);
+#else
+ __VLTRegisterSet (&maps[i], (char *) key_buffer, 128, 100,
+ (void **) &temp_array);
+#endif
+ }
+ }
+
+ __VLTChangePermission(__VLTP_READ_ONLY);
+
+ return 0;
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/register_set_pair_inserts.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/register_set_pair_inserts.cc
new file mode 100644
index 000000000..297e87567
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/register_set_pair_inserts.cc
@@ -0,0 +1,106 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "vtv_utils.h"
+#include "vtv_rts.h"
+
+/* This configuration will test mostly inserting of new elements since
+ the number of repeats is 1. It should also do a lot of rehashing */
+
+/* This test case may fail depending on the system configuration.
+ Check the value of /proc/sys/vm/max_map_count and fix by doing
+ Ex: sudo sh -c "echo 131060 > /proc/sys/vm/max_map_count" */
+
+#define NUM_MAPS 40000
+#define ELEMENTS_PER_MAP 100
+#define NUM_REPEATS 1
+
+#define KEY_TYPE_FIXED_SIZE 8
+void *key_buffer = malloc (17);
+typedef char * name_string;
+name_string fake_names[NUM_MAPS];
+
+/* This variable has to be put in rel.ro */
+void * maps[NUM_MAPS] VTV_PROTECTED_VAR;
+
+struct fake_vt {
+ void * fake_vfp [4];
+};
+void * fake_vts [NUM_MAPS * ELEMENTS_PER_MAP];
+
+
+void
+generate_names (void)
+{
+ int i;
+
+ for (i = 0; i < NUM_MAPS; ++i)
+ {
+ fake_names[i] = (char *) malloc (9 * sizeof (char));
+ snprintf (fake_names[i], 9, "name%d", i);
+ }
+}
+
+static uint32_t
+vtv_string_hash(const char *in)
+{
+ const char *s = in;
+ uint32_t h = 0;
+
+ for ( ; *s; ++s)
+ h = 5 * h + *s;
+ return h;
+}
+
+int main()
+{
+ __VLTChangePermission(__VLTP_READ_WRITE);
+
+ generate_names();
+
+ for (int k = 0; k < NUM_REPEATS; k++)
+ {
+ int curr_fake_vt = 0;
+ for (int i = 0; i < NUM_MAPS; i++)
+ {
+ uint32_t *value_ptr = (uint32_t *) key_buffer;
+ uint32_t len1 = strlen (fake_names[i]);
+ uint32_t hash_value = vtv_string_hash (fake_names[i]);
+ void *temp_array[ELEMENTS_PER_MAP];
+
+ *value_ptr = len1;
+ value_ptr++;
+ *value_ptr = hash_value;
+
+ memcpy ((char *) key_buffer + KEY_TYPE_FIXED_SIZE, fake_names[i],
+ len1);
+
+
+#ifdef VTV_DEBUG
+ __VLTRegisterPairDebug (&maps[i], (char *) key_buffer, 128,
+ &fake_vts[curr_fake_vt], "", "");
+#else
+ __VLTRegisterPair (&maps[i], (char *) key_buffer, 128,
+ &fake_vts[curr_fake_vt]);
+#endif
+ for (int j = 0; j < ELEMENTS_PER_MAP; j++)
+ {
+ temp_array[j] = &fake_vts[curr_fake_vt];
+ curr_fake_vt++;
+ }
+#ifdef VTV_DEBUG
+ __VLTRegisterSetDebug (&maps[i], (char *) key_buffer, 128, 100,
+ (void **) &temp_array);
+#else
+ __VLTRegisterSet (&maps[i], (char *) key_buffer, 128, 100,
+ (void **) &temp_array);
+#endif
+ }
+ }
+
+ __VLTChangePermission(__VLTP_READ_ONLY);
+
+ return 0;
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/template-list-iostream.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/template-list-iostream.cc
new file mode 100644
index 000000000..06ec3b01e
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/template-list-iostream.cc
@@ -0,0 +1,120 @@
+// { dg-do run }
+
+#include <assert.h>
+#include <iostream>
+#include <fstream>
+
+using std::ofstream;
+using std::ifstream;
+using std::ios;
+
+extern "C" int printf(const char *, ...);
+
+class Subscriptor
+{
+ public:
+
+ Subscriptor() : counter(1) {}
+
+ virtual ~Subscriptor()
+ {
+ counter--;
+ assert(counter == 0);
+ }
+
+ private:
+ mutable int counter;
+};
+
+template <int dim> struct Function
+{
+ Function(int i): value(dim + i) {}
+ int value;
+};
+
+template <int dim> struct Triangulation
+{
+
+};
+
+template <int dim> struct Exercise_2_3
+{
+ enum { DIM = dim };
+};
+
+ template <int dim>
+ struct SetUpBase : public Subscriptor
+ {
+ virtual
+ const Function<dim> get_boundary_values () const = 0;
+
+ virtual
+ const Function<dim> get_right_hand_side () const = 0;
+
+ // virtual
+ // void create_coarse_grid (Triangulation<dim> &coarse_grid) const = 0;
+ };
+
+ template <class Traits, int dim>
+ struct SetUp : public SetUpBase<dim>
+ {
+ SetUp () {};
+
+ virtual
+ const Function<dim> get_boundary_values () const
+ { return Function<dim>(Traits::DIM); }
+
+ virtual
+ const Function<dim> get_right_hand_side () const
+ { return Function<dim>(Traits::DIM); }
+
+ // virtual
+ // void create_coarse_grid (Triangulation<dim> &coarse_grid) const;
+
+ // static const typename Traits::BoundaryValues boundary_values;
+ // static const typename Traits::RightHandSide right_hand_side;
+ };
+
+
+void myread(std::istream * in)
+{
+ char input_str[50] = "\0";
+ if (in->good())
+ (*in) >> input_str;
+ std::cout << input_str << std::endl;
+ delete in;
+}
+
+
+
+int main()
+{
+ /*
+
+ SetUp<Exercise_2_3<1000>, 2> s1a;
+ SetUp<Exercise_2_3<2000>, 1> s2;
+ SetUp<Exercise_2_3<2000>, 2> s2a;
+ return s1->get_boundary_values().value + s1a.get_boundary_values().value +
+ s2.get_boundary_values().value + s2a.get_boundary_values().value +
+ s1->get_right_hand_side().value + s1a.get_right_hand_side().value +
+ s2.get_right_hand_side().value + s2a.get_right_hand_side().value;
+ */
+
+ SetUp<Exercise_2_3<1000>, 1> * s1 = new SetUp<Exercise_2_3<1000>, 1>();
+
+ printf("%d\n", s1->get_boundary_values().value);
+
+ ifstream * infile = new ifstream("./template-list-iostream.cc");
+
+ myread(infile);
+
+ ofstream * outfile = new ofstream("/tmp/xxx.txt");
+
+ if (outfile->good())
+ (*outfile) << "hello there" << std::endl;
+ std::cerr << "Reached End" << std::endl;
+
+ delete outfile;
+
+ return 0;
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/template-list.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/template-list.cc
new file mode 100644
index 000000000..aeb2db9e5
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/template-list.cc
@@ -0,0 +1,94 @@
+// { dg-do run }
+
+#include <assert.h>
+
+extern "C" int printf(const char *, ...);
+
+class Subscriptor
+{
+ public:
+
+ Subscriptor() : counter(1) {}
+
+ virtual ~Subscriptor()
+ {
+ counter--;
+ assert(counter == 0);
+ }
+
+ private:
+ mutable int counter;
+};
+
+template <int dim> struct Function
+{
+ Function(int i): value(dim + i) {}
+ int value;
+};
+
+template <int dim> struct Triangulation
+{
+
+};
+
+template <int dim> struct Exercise_2_3
+{
+ enum { DIM = dim };
+};
+
+ template <int dim>
+ struct SetUpBase : public Subscriptor
+ {
+ virtual
+ const Function<dim> get_boundary_values () const = 0;
+
+ virtual
+ const Function<dim> get_right_hand_side () const = 0;
+
+ // virtual
+ // void create_coarse_grid (Triangulation<dim> &coarse_grid) const = 0;
+ };
+
+ template <class Traits, int dim>
+ struct SetUp : public SetUpBase<dim>
+ {
+ SetUp () {};
+
+ virtual
+ const Function<dim> get_boundary_values () const
+ { return Function<dim>(Traits::DIM); }
+
+ virtual
+ const Function<dim> get_right_hand_side () const
+ { return Function<dim>(Traits::DIM); }
+
+ // virtual
+ // void create_coarse_grid (Triangulation<dim> &coarse_grid) const;
+
+ // static const typename Traits::BoundaryValues boundary_values;
+ // static const typename Traits::RightHandSide right_hand_side;
+ };
+
+
+int main()
+{
+ /*
+
+ SetUp<Exercise_2_3<1000>, 2> s1a;
+ SetUp<Exercise_2_3<2000>, 1> s2;
+ SetUp<Exercise_2_3<2000>, 2> s2a;
+ return s1->get_boundary_values().value + s1a.get_boundary_values().value +
+ s2.get_boundary_values().value + s2a.get_boundary_values().value +
+ s1->get_right_hand_side().value + s1a.get_right_hand_side().value +
+ s2.get_right_hand_side().value + s2a.get_right_hand_side().value;
+ */
+#ifndef NFAIL
+ SetUp<Exercise_2_3<1000>, 1> * s1 = new SetUp<Exercise_2_3<1000>, 1>();
+ printf("%d\n", s1->get_boundary_values().value);
+ return 0;
+#else
+ SetUp<Exercise_2_3<1000>, 1> s1;
+ printf("%d\n", s1.get_boundary_values().value);
+ return 0;
+#endif
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/template-list2.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/template-list2.cc
new file mode 100644
index 000000000..3df8d3724
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/template-list2.cc
@@ -0,0 +1,46 @@
+// { dg-do run }
+
+#include <assert.h>
+
+extern "C" int printf(const char *, ...);
+
+class Subscriptor
+{
+ public:
+
+ Subscriptor()
+ { counter = 1;}
+
+ virtual ~Subscriptor()
+ {
+ counter--;
+ assert(counter == 0);
+ }
+
+ private:
+ static int counter;
+};
+
+int Subscriptor::counter;
+
+template <typename number>
+class Polynomial : public Subscriptor
+{
+};
+
+class LagrangeEquidistant: public Polynomial<double>
+{
+};
+
+template<typename _Tp>
+inline void
+_MyDestroy(_Tp* __pointer)
+ { __pointer->~_Tp(); }
+
+int main()
+{
+ LagrangeEquidistant * s1 = new LagrangeEquidistant;
+ _MyDestroy(s1);
+
+ return 0;
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/test1.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/test1.cc
new file mode 100644
index 000000000..9005826df
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/test1.cc
@@ -0,0 +1,74 @@
+// { dg-do run }
+
+// Small test case from povray, see if it reproduces.
+
+#include <stdio.h>
+
+class POVMS_MessageReceiver
+{
+
+private:
+ int x;
+ class Handler
+ {
+ public:
+ virtual void print() = 0;
+ };
+protected:
+ template<class T> class MemberHandler : public Handler
+ {
+ public:
+ MemberHandler(T *xx)
+ {
+ x = xx;
+ }
+
+ ~MemberHandler() {}
+
+ void print()
+ {
+ printf("In print\n");
+ }
+ private:
+ T *x;
+ };
+
+private:
+ struct HandlerNode
+ {
+ Handler *handler;
+ };
+
+ HandlerNode *receiver;
+public:
+ POVMS_MessageReceiver(int xx) : x(xx) {}
+ ~POVMS_MessageReceiver() {}
+
+ void foo(int *xx);
+ void try_call();
+};
+
+void POVMS_MessageReceiver::foo(int *xx)
+{
+ receiver = new HandlerNode;
+
+ receiver->handler = new MemberHandler<int>(xx);
+}
+
+void POVMS_MessageReceiver::try_call()
+{
+ receiver->handler->print();
+}
+
+
+int main()
+{
+ int loc = 34;
+ POVMS_MessageReceiver a_test(100);
+
+ a_test.foo(&loc);
+ a_test.try_call();
+}
+
+
+
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/thunk.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/thunk.cc
new file mode 100644
index 000000000..bec1057f5
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/thunk.cc
@@ -0,0 +1,37 @@
+// { dg-do run }
+
+#include <assert.h>
+struct A {
+ A():value(123) {}
+ int value;
+ virtual int access() { return this->value; }
+};
+struct B {
+ B():value(456) {}
+ int value;
+ virtual int access() { return this->value; }
+};
+struct C : public A, public B {
+ C():better_value(789) {}
+ int better_value;
+ virtual int access() { return this->better_value; }
+};
+struct D: public C {
+ D():other_value(987) {}
+ int other_value;
+ virtual int access() { return this->other_value; }
+};
+
+int use(B *b)
+{
+ return b->access();
+}
+
+int main()
+{
+ C c;
+ assert(use(&c) == 789);
+ D d;
+ assert(use(&d) == 987);
+ return 0;
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/thunk_vtable_map_attack.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/thunk_vtable_map_attack.cc
new file mode 100644
index 000000000..51f974ee4
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/thunk_vtable_map_attack.cc
@@ -0,0 +1,113 @@
+// { dg-do run }
+
+#include <assert.h>
+#include <signal.h>
+#include <setjmp.h>
+#include <stdio.h>
+
+#include <iostream>
+#include <fstream>
+
+using std::ofstream;
+using std::ifstream;
+using std::ios;
+
+struct A {
+ A():value(123) {}
+ int value;
+ virtual int access() { return this->value; }
+};
+struct B {
+ B():value(456) {}
+ int value;
+ virtual int access() { return this->value; }
+};
+struct C : public A, public B {
+ C():better_value(789) {}
+ int better_value;
+ virtual int access() { return this->better_value; }
+};
+struct D: public C {
+ D():other_value(987) {}
+ int other_value;
+ virtual int access() { return this->other_value; }
+};
+
+volatile static int signal_count = 0;
+
+sigjmp_buf before_segv;
+
+static void
+handler(int sig, siginfo_t *si, void *unused)
+{
+ /*
+ printf("Got SIGSEGV at address: 0x%lx\n",
+ (long) si->si_addr);
+ */
+
+ signal_count++;
+ /* You are not supposed to longjmp out of a signal handler but it seems
+ to work for this test case and it simplifies it */
+ siglongjmp(before_segv, 1);
+ /* exit(1); */
+}
+
+/* Access one of the vtable_map variables generated by this .o */
+extern void * _ZN4_VTVI1BE12__vtable_mapE;
+
+/* Access one of the vtable_map variables generated by libstdc++ */
+extern void * _ZN4_VTVISt8ios_baseE12__vtable_mapE;
+
+int use(B *b)
+{
+ int ret;
+
+ ret = sigsetjmp(before_segv, 1);
+ if (ret == 0)
+ {
+ /* This should generate a segmentation violation. ie: at this point it should
+ be protected */
+ _ZN4_VTVI1BE12__vtable_mapE = 0;
+ }
+ assert(ret == 1 && signal_count == 1);
+
+ ret = sigsetjmp(before_segv, 1);
+ if (ret == 0)
+ {
+ /* Try to modify one of the vtable_map variables in the stdc++ library.
+ This should generate a segmentation violation. ie: at this point it
+ should be protected */
+ _ZN4_VTVISt8ios_baseE12__vtable_mapE = 0;
+ }
+ assert(ret == 1 && signal_count == 2);
+
+ return b->access();
+}
+
+void myread(std::istream * in)
+{
+ char input_str[50] = "\0";
+ if (in->good())
+ (*in) >> input_str;
+ std::cout << input_str << std::endl;
+ delete in;
+}
+
+int main()
+{
+ ifstream * infile = new ifstream("./thunk_vtable_map_attack.cpp");
+ myread(infile);
+
+ /* Set up handler for SIGSEGV. */
+ struct sigaction sa;
+ sa.sa_flags = SA_SIGINFO;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_sigaction = handler;
+ if (sigaction(SIGSEGV, &sa, NULL) == -1)
+ assert(0);
+
+ C c;
+ assert(use(&c) == 789);
+
+ return 0;
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/v8-test-2.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/v8-test-2.cc
new file mode 100644
index 000000000..6bfda56e8
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/v8-test-2.cc
@@ -0,0 +1,97 @@
+// { dg-do run }
+
+#include <stdlib.h>
+#include <string>
+
+class Literal;
+class CallRuntime;
+
+class AstNode {
+public:
+
+ enum Type {
+ kLiteral, kCallRuntime,
+ kInvalid = -1
+ };
+
+ AstNode() { }
+
+ virtual ~AstNode() { }
+
+ virtual Type node_type() const = 0;
+
+ bool
+ IsLiteral() { return node_type() == AstNode::kLiteral; }
+
+ Literal *
+ AsLiteral() { return IsLiteral() ? reinterpret_cast<Literal*>(this)
+ : NULL; }
+
+ bool
+ IsCallRuntime() { return node_type() == AstNode::kCallRuntime; }
+
+ CallRuntime *
+ AsCallRuntime() { return IsCallRuntime() ? reinterpret_cast<CallRuntime*>(this)
+ : NULL; }
+
+};
+
+class Expression: public AstNode {
+public:
+private:
+ int id_;
+};
+
+class Literal: public Expression {
+public:
+
+ virtual AstNode::Type node_type() const { return AstNode::kLiteral; }
+
+ private:
+ std::string ToString();
+
+};
+
+class CallRuntime: public Expression {
+public:
+
+ virtual AstNode::Type node_type() const { return AstNode::kCallRuntime; }
+
+ private:
+ std::string name_;
+};
+
+Expression *
+ExpressionCheck (bool *ok)
+{
+ if (*ok == true)
+ return new CallRuntime();
+ else
+ return new Literal ();
+
+ return NULL;
+}
+
+Expression *
+GetExpression (bool *ok)
+{
+ Expression *expression = ExpressionCheck (ok);
+ Expression *return_expr = NULL;
+
+ if (expression != NULL && expression->AsLiteral() != NULL)
+ return_expr = new Literal();
+ else if (expression != NULL && expression->AsCallRuntime() != NULL)
+ return_expr = expression;
+
+ return return_expr;
+}
+
+int
+main (int argc, char **argv)
+{
+ bool a_bool = true;
+
+ AstNode *node = GetExpression (&a_bool);
+
+ return 0;
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/virtfunc-test.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/virtfunc-test.cc
new file mode 100644
index 000000000..3ad12b896
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/virtfunc-test.cc
@@ -0,0 +1,222 @@
+// { dg-do run }
+
+/* This test script is part of GDB, the GNU debugger.
+
+ Copyright 1993, 1994, 1997, 1998, 1999, 2003, 2004,
+ 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 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, see <http://www.gnu.org/licenses/>.
+ */
+
+// Pls try the following program on virtual functions and try to do print on
+// most of the code in main(). Almost none of them works !
+
+//
+// The inheritance structure is:
+//
+// V : VA VB
+// A : (V)
+// B : A
+// D : AD (V)
+// C : (V)
+// E : B (V) D C
+//
+
+class VA
+{
+public:
+ int va;
+};
+
+class VB
+{
+public:
+ int vb;
+ int fvb();
+ virtual int vvb();
+};
+
+class V : public VA, public VB
+{
+public:
+ int f();
+ virtual int vv();
+ int w;
+};
+
+class A : virtual public V
+{
+public:
+ virtual int f();
+private:
+ int a;
+};
+
+class B : public A
+{
+public:
+ int f();
+private:
+ int b;
+};
+
+class C : public virtual V
+{
+public:
+ int c;
+};
+
+class AD
+{
+public:
+ virtual int vg() = 0;
+};
+
+class D : public AD, virtual public V
+{
+public:
+ static void s();
+ virtual int vg();
+ virtual int vd();
+ int fd();
+ int d;
+};
+
+class E : public B, virtual public V, public D, public C
+{
+public:
+ int f();
+ int vg();
+ int vv();
+ int e;
+};
+
+D dd;
+D* ppd = &dd;
+AD* pAd = &dd;
+
+A a;
+B b;
+C c;
+D d;
+E e;
+V v;
+VB vb;
+
+
+A* pAa = &a;
+A* pAe = &e;
+
+B* pBe = &e;
+
+D* pDd = &d;
+D* pDe = &e;
+
+V* pVa = &a;
+V* pVv = &v;
+V* pVe = &e;
+V* pVd = &d;
+
+AD* pADe = &e;
+
+E* pEe = &e;
+
+VB* pVB = &vb;
+
+void init()
+{
+ a.vb = 1;
+ b.vb = 2;
+ c.vb = 3;
+ d.vb = 4;
+ e.vb = 5;
+ v.vb = 6;
+ vb.vb = 7;
+
+ d.d = 1;
+ e.d = 2;
+}
+
+extern "C" int printf(const char *, ...);
+
+int all_count = 0;
+int failed_count = 0;
+
+#define TEST(EXPR, EXPECTED) \
+ ret = EXPR; \
+ if (ret != EXPECTED) {\
+ printf("Failed %s is %d, should be %d!\n", #EXPR, ret, EXPECTED); \
+ failed_count++; } \
+ all_count++;
+
+int ret;
+
+void test_calls()
+{
+ TEST(pAe->f(), 20);
+ TEST(pAa->f(), 1);
+
+ TEST(pDe->vg(), 202);
+ TEST(pADe->vg(), 202);
+ TEST(pDd->vg(), 101);
+
+ TEST(pEe->vvb(), 411);
+
+ TEST(pVB->vvb(), 407);
+
+ TEST(pBe->vvb(), 411);
+ TEST(pDe->vvb(), 411);
+
+ TEST(pEe->vd(), 282);
+ TEST(pEe->fvb(), 311);
+
+ TEST(pEe->D::vg(), 102);
+ printf("Did %d tests, of which %d failed.\n", all_count, failed_count);
+}
+#ifdef usestubs
+extern "C" {
+ void set_debug_traps();
+ void breakpoint();
+};
+#endif
+
+int main()
+{
+#ifdef usestubs
+ set_debug_traps();
+ breakpoint();
+#endif
+ init();
+
+ e.w = 7;
+ e.vb = 11;
+
+ test_calls();
+ return 0;
+
+}
+
+int A::f() {return 1;}
+int B::f() {return 2;}
+void D::s() {}
+int E::f() {return 20;}
+int D::vg() {return 100+d;}
+int E::vg() {return 200+d;}
+int V::f() {return 600+w;}
+int V::vv() {return 400+w;}
+int E::vv() {return 450+w;}
+int D::fd() {return 250+d;}
+int D::vd() {return 280+d;}
+int VB::fvb() {return 300+vb;}
+int VB::vvb() {return 400+vb;}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/virtual_inheritance.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/virtual_inheritance.cc
new file mode 100644
index 000000000..1c49c9664
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/virtual_inheritance.cc
@@ -0,0 +1,48 @@
+// { dg-do run }
+
+#include <assert.h>
+struct V {
+ V(): virtual_value(-123) {}
+ int virtual_value;
+ virtual int access_vv() { return virtual_value; }
+};
+
+struct A: virtual public V {
+ A():value(123) {}
+ int value;
+ virtual int access() { return value; }
+};
+struct B: virtual public V {
+ B():value(456) {}
+ int value;
+ virtual int access() { return value; }
+};
+struct C : public A, public B {
+ C():better_value(789) {}
+ int better_value;
+ virtual int access() { return better_value; }
+};
+struct D: public A, public B {
+ D():better_virtual_value(-345) {}
+ int better_virtual_value;
+ virtual int access_vv() { return better_virtual_value; }
+};
+
+int use(B *b)
+{
+ return b->access();
+}
+
+int v_use(V * v)
+{
+ return v->access_vv();
+}
+
+int main()
+{
+ C c;
+ assert(v_use(&c) == -123);
+ D d;
+ assert(v_use(&d) == -345);
+ return 0;
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/vtv.exp b/gcc-4.9/libvtv/testsuite/libvtv.cc/vtv.exp
new file mode 100644
index 000000000..12ed77431
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/vtv.exp
@@ -0,0 +1,83 @@
+load_lib libvtv-dg.exp
+load_gcc_lib gcc-dg.exp
+
+global VTV_FLAGS
+set VTV_FLAGS [list {-O0} {-O2}]
+
+libvtv_init c++
+
+set shlib_ext [get_shlib_extension]
+set lang_link_flags "-shared-libgcc -lstdc++"
+set lang_test_file_found 0
+set lang_library_path "../libstdc++-v3/src/.libs"
+
+dg-init
+
+set blddir [lookfor_file [get_multilibs] libvtv]
+
+# Find the correct libstdc++ library to use.
+
+if { $blddir != "" } {
+ # Look for a static libstdc++ first.
+ if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
+ set lang_test_file "${lang_library_path}/libstdc++.a"
+ set lang_test_file_found 1
+ # We may have a shared only build, so look for a shared libstdc++.
+ } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] {
+ set lang_test_file "${lang_library_path}/libstdc++.${shlib_ext}"
+ set lang_test_file_found 1
+ } else {
+ puts "looking for ${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"
+ puts "No libstdc++ library found, will not execute c++ tests"
+ }
+} elseif { [info exists GXX_UNDER_TEST] } {
+ set lang_test_file_found 1
+ # Needs to exist for libvtv.exp.
+ set lang_test_file ""
+} else {
+ puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
+}
+
+
+global srcdir
+
+if { $lang_test_file_found } {
+ # Set the path for finding libstdc++.
+ if { $blddir != "" } {
+ set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
+ } else {
+ set ld_library_path "$always_ld_library_path"
+ }
+ append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
+ set_ld_library_path_env_vars
+
+ # Make sure we can find the libstdc++ header files.
+ set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
+ if { [file exists $flags_file] } {
+ set libstdcxx_includes [exec sh $flags_file --build-includes]
+ } else {
+ set libstdcxx_includes ""
+ }
+
+ # Run the tests with -fvtable-verify=std
+ foreach flags $VTV_FLAGS {
+ foreach srcfile [lsort [glob -nocomplain ${srcdir}/libvtv.cc/*.cc]] {
+ dg-runtest $srcfile "$flags -fvtable-verify=std" $libstdcxx_includes
+ }
+
+ foreach srcfile [lsort [glob -nocomplain ${srcdir}/libvtv.cc/@*.list]] {
+ dg-runtest $srcfile "$flags -fvtable-verify=std" $libstdcxx_includes
+ }
+ }
+
+ # Run the tests with -fvtable-verify=preinit
+ foreach flags $VTV_FLAGS {
+ foreach srcfile [lsort [glob -nocomplain ${srcdir}/libvtv.cc/*.cc]] {
+ dg-runtest $srcfile "$flags -fvtable-verify=preinit" $libstdcxx_includes
+ }
+
+ foreach srcfile [lsort [glob -nocomplain ${srcdir}/libvtv.cc/@*.list]] {
+ dg-runtest $srcfile "$flags -fvtable-verify=preinit" $libstdcxx_includes
+ }
+ }
+}
diff --git a/gcc-4.9/libvtv/testsuite/libvtv.cc/xlan-test.cc b/gcc-4.9/libvtv/testsuite/libvtv.cc/xlan-test.cc
new file mode 100644
index 000000000..213ed613f
--- /dev/null
+++ b/gcc-4.9/libvtv/testsuite/libvtv.cc/xlan-test.cc
@@ -0,0 +1,185 @@
+// { dg-do run }
+
+#include <stdio.h>
+#include <stdlib.h>
+
+class XMemory
+{
+public:
+ void * operator new (size_t size);
+ void operator delete (void *p);
+
+protected:
+ XMemory () {}
+
+ virtual ~XMemory() {}
+};
+
+class XSerializable
+{
+public:
+ virtual ~XSerializable () {};
+
+ virtual bool isSerializable() const = 0;
+ virtual void serialize () = 0;
+
+protected:
+ XSerializable() {};
+
+};
+
+class Grammar: public XSerializable, public XMemory
+{
+public:
+ enum GrammarType {
+ DTDGrammarType,
+ SchemaGrammarType,
+ OtherGrammarType,
+ Unknown
+ };
+
+ virtual ~Grammar() {}
+
+ virtual GrammarType getGrammarType() const = 0;
+ virtual bool getValidated() const = 0;
+
+ virtual bool isSerializable() const;
+ virtual void serialize ();
+
+protected:
+ Grammar() {};
+
+};
+
+class SchemaGrammar : public Grammar
+{
+public:
+
+ SchemaGrammar () : Grammar(), elemID(10) { fValidated = true; }
+
+ virtual ~SchemaGrammar() {}
+
+ virtual Grammar::GrammarType getGrammarType() const;
+ virtual bool getValidated() const;
+
+ virtual bool isSerializable () const;
+ virtual void serialize ();
+
+private:
+ const unsigned int elemID;
+ bool fValidated;
+
+};
+
+class OtherGrammar : public Grammar
+{
+public:
+
+ OtherGrammar () : Grammar(), elemID(10) { fValidated = true; }
+
+ virtual ~OtherGrammar() {}
+
+ virtual Grammar::GrammarType getGrammarType() const;
+ virtual bool getValidated() const;
+
+ virtual bool isSerializable () const;
+ virtual void serialize ();
+
+private:
+ const unsigned int elemID;
+ bool fValidated;
+
+};
+
+void
+Grammar::serialize ()
+{
+ printf ("in Grammar::serialize\n");
+}
+
+bool
+Grammar::isSerializable () const
+{
+ return true;
+}
+
+bool
+SchemaGrammar::isSerializable () const
+{
+ return true;
+}
+
+void
+SchemaGrammar::serialize ()
+{
+ printf ("in SchemaGrammar::serialize\n");
+}
+
+Grammar::GrammarType
+SchemaGrammar::getGrammarType() const {
+ return Grammar::SchemaGrammarType;
+}
+
+bool
+SchemaGrammar::getValidated () const
+{
+ return fValidated;
+}
+
+void *
+XMemory::operator new (size_t size)
+{
+ return malloc (size);
+}
+
+void
+XMemory::operator delete (void *p)
+{
+}
+
+bool
+OtherGrammar::isSerializable () const
+{
+ return false;
+}
+
+void
+OtherGrammar::serialize ()
+{
+ printf ("in OtherGrammar::serialize\n");
+}
+
+Grammar::GrammarType
+OtherGrammar::getGrammarType() const {
+ return Grammar::OtherGrammarType;
+}
+
+bool
+OtherGrammar::getValidated () const
+{
+ return fValidated;
+}
+
+int
+main (int argc, char **argv)
+{
+ SchemaGrammar sPtr;
+ OtherGrammar oPtr;
+ Grammar &sGrammar = sPtr;
+
+ for (int i = 0; i < 2; ++i)
+ {
+ if (i == 0)
+ sGrammar = oPtr;
+ else
+ sGrammar = sPtr;
+
+ if (sGrammar.getGrammarType() != Grammar::SchemaGrammarType ||
+ sGrammar.getValidated ())
+ printf ("if condition was true.\n");
+ else
+ printf ("if condition was false.\n");
+ }
+
+ return 0;
+}