Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / g++.old-deja / g++.robertl / eb27.C
blob204a143d619c9bec00f4e3bd6be7626864a10b5a
1 // { dg-do assemble  }
2 // { dg-options "-Wno-deprecated" }
3 /* bug.cc */
4 /* simple program to demonstrate the bug with named return values in gcc
5 */
6 /* (w) 4.9.97 by Kurt Garloff <K.Garloff@ping.de> */
7 // 8/28/1998 - This dies in add_conversions from dfs_walk, null CLASSTYPE_METHOD_VEC
8 // for the test<T> record_type.  This is marked as an expected failure for now,
9 // until we actually fix it.
11 #include <iostream>
13 template <class T> class test;
14 template <class T> test<T> operator + (const test<T>& a, const test<T>& b);
16 // A simple numerical class
17 template <class T>
18 class test
20    T elem;
21  public:
22    test ()  { elem = 0; };
23    test (const T& a)  { elem = a; };
24    test<T>& operator += (const test<T>& a)  { elem += a.elem; return *this; };
25    friend test<T> operator + <> (const test<T>&, const test<T>&);
26    friend std::ostream& operator << (std::ostream& os, const test<T>& a)
27      { return os << a.elem; };
30 // named return value version
31 template <class T>
32 test<T> operator + (const test<T>& a, const test<T>& b) return c(a);// { dg-error "" } named return value
33 { c += b; } // { dg-error "" } c undeclared
35 int main()
37    test<int> x, y;
38    x += 5; 
39    std::cout << x << std::endl;
40    y = x + test<int>(2); 
41    std::cout << y << std::endl;