* partord1.C: New test.
From-SVN: r27887
This commit is contained in:
parent
5ec024f064
commit
5f04b62707
@ -1,4 +1,6 @@
|
||||
1999-07-01 Alexandre Oliva <oliva@dcc.unicamp.br>
|
||||
|
||||
* partord1.C: New test.
|
||||
|
||||
* template1.C: New test.
|
||||
|
||||
|
28
gcc/testsuite/g++.old-deja/g++.oliva/partord1.C
Normal file
28
gcc/testsuite/g++.old-deja/g++.oliva/partord1.C
Normal file
@ -0,0 +1,28 @@
|
||||
// Build don't link:
|
||||
|
||||
// Copyright (C) 1999 Free Software Foundation
|
||||
|
||||
// by Alexandre Oliva <oliva@dcc.unicamp.br>
|
||||
|
||||
template <typename T> void foo(T);
|
||||
template <typename T> void foo(T*);
|
||||
|
||||
template <typename T> class bar {
|
||||
private:
|
||||
int i; // ERROR - this variable
|
||||
friend void foo<T>(T);
|
||||
};
|
||||
|
||||
template <typename T> void foo(T) {
|
||||
bar<T>().i = 0; // ok, I'm a friend
|
||||
}
|
||||
template <typename T> void foo(T*) {
|
||||
bar<T*>().i = 1; // ERROR - not a friend
|
||||
}
|
||||
|
||||
int main() {
|
||||
int j = 0;
|
||||
foo(j); // calls foo<int>(int), ok
|
||||
foo(&j); // calls foo<int>(int*) // ERROR - not a friend
|
||||
foo<int*>(&j); // calls foo<int*>(int*), ok
|
||||
}
|
Loading…
Reference in New Issue
Block a user