2 // { dg-options "-Wno-deprecated" }
4 /* simple program to demonstrate the bug with named return values in gcc
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.
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
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
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
39 std::cout << x << std::endl;
41 std::cout << y << std::endl;