Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.robertl/eb44.C

raw
1 // { dg-do assemble }
2 // { dg-skip-if "requires hosted libstdc++ for cstdio" { ! hostedlib } }
3 // spurious 'const' in error.
4 // For egcs-2.91.34, the warning message refers to
5 // class ostream & operator <<(class ostream &, const class Vector<T> &)
6 // Also, the template instantiation does not provide the missing
7 // friend function, the non-template function does
8
9 #include <cstdio>
10 #include <cstdlib>
11 #include <iostream>
12
13 using namespace std;
14
15 template <class T>
16 class Vector
17 {
18 friend ostream& operator<< (ostream& out, const Vector<T> & vec); // { dg-warning "non-template" "warn" }
19 // { dg-message "note" "note" { target *-*-* } .-1 }
20 };
21
22 template <class T>
23 ostream& operator<< (ostream& out, const Vector<T> & vec)
24 {
25 abort(); // this should not be called
26 }
27
28 template class Vector<char>;
29 template ostream& operator<< (ostream& out, const Vector<char> &);
30
31 ostream& operator<< (ostream& out, const Vector<char>&)
32 {
33 return out;
34 }
35
36 int main()
37 {
38 Vector<char> vc;
39 cout << vc;
40 }