| 1 |
// { dg-do assemble } |
| 2 |
|
| 3 |
// Copyright (C) 1999 Free Software Foundation |
| 4 |
|
| 5 |
// by Alexandre Oliva <[email protected]> |
| 6 |
|
| 7 |
template <typename T> void foo(T); |
| 8 |
template <typename T> void foo(T*); |
| 9 |
|
| 10 |
template <typename T> class bar { |
| 11 |
private: |
| 12 |
int i; // { dg-message "" } this variable |
| 13 |
friend void foo<T>(T); |
| 14 |
}; |
| 15 |
|
| 16 |
template <typename T> void foo(T) { |
| 17 |
bar<T>().i; // ok, I'm a friend |
| 18 |
} |
| 19 |
template <typename T> void foo(T*) { |
| 20 |
bar<T*>().i; // { dg-error "" } not a friend |
| 21 |
} |
| 22 |
|
| 23 |
int main() { |
| 24 |
int j = 0; |
| 25 |
foo(j); // calls foo<int>(int), ok |
| 26 |
foo(&j); // calls foo<int>(int*) |
| 27 |
foo<int*>(&j); // calls foo<int*>(int*), ok |
| 28 |
} |