Fix test-suite fallout of default -Wreturn-type.
[official-gcc.git] / gcc / testsuite / g++.dg / ipa / devirt-29.C
blobb4f24a1044ca7bb4c8a9758a50b7733db8166105
1 /* { dg-do run { target c++11 } } */
2 /* There is a devirtualizable call. In PR60306 we deduced wrong target to cxa_pure_virtual.
3    For gcc 4.10 we temporarily disable the devirtualization.  */
4 /* { dg-options "-O3"  } */
6 #include <vector>
8 using std::vector;
10 class Object 
12 public:
14   virtual Object* clone() const =0;
16   virtual int type() const {return 0;}
18   Object& operator=(const Object&) {return *this;}
20   Object() {}
21   Object(const Object&) {}
22   virtual ~Object() {}
25 Object* f(const Object&o)
27   return o.clone();
30 template<typename T>
31 class Box: public Object, public T
33 public:
34   Box<T>* clone() const {return new Box<T>(*this);}
36   Box<T>& operator=(const Box<T>& t)
37   {
38     T::operator=(t);
39     return *this;
40   }
42   Box<T>& operator=(const T& t)
43   {
44     T::operator=(t);
45     return *this;
46   }
48   Box() = default;
49   Box(const Box<T>&) = default;
50   explicit Box(const T& t):T(t) {}
53 template <typename T>
54 using Vector = Box<vector<T>>;
56 typedef Vector<int> OVector;
58 OVector edges_connecting_to_node(int n)
60   OVector branch_list_;
61   for(int i=0;i<n;i++)
62     branch_list_.push_back(i);
64   return branch_list_;
67 int main(int argc,char* argv[])
68
69   for(int n=0; n < argc; n++)
70   {
71     auto x = edges_connecting_to_node(1);
72     x.clone();
73     f(x);
74   }