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