2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / friend4.C
blob41d3a6a487e0869e2572b1d24f00be9cf87b26ee
1 // { dg-do assemble  }
3 // by Alexandre Oliva <oliva@dcc.unicamp.br>
5 // I'm not 100% sure this program is correct, but g++ shouldn't just
6 // crash.
8 // The idea is to give privileged access to bar<A> only to
9 // specializations foo<A,B>, for all B.
11 template <class A, class B> void foo();
12 template <class C> class bar {
13   int i; // { dg-error "" } private
14   template <class B> friend void foo<C,B>(); // { dg-error "" } bogus declaration
16 template <class A, class B> void foo() {
17   bar<A> baz; baz.i = 1;   // { dg-error "" } foo cannot access bar<int>::i
18   bar<int> buz; buz.i = 1; // { dg-error "" } foo cannot access bar<int>::i
20 int main() {
21   foo<void,void>();
22   foo<int,void>();