blob: 34fe92e64076fbeaf5f8412db440eceaf8f20446 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
// { dg-do assemble }
// 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; // { dg-error "" } this variable
friend void foo<T>(T);
};
template <typename T> void foo(T) {
bar<T>().i; // ok, I'm a friend
}
template <typename T> void foo(T*) {
bar<T*>().i; // { dg-error "" } not a friend
}
int main() {
int j = 0;
foo(j); // calls foo<int>(int), ok
foo(&j); // calls foo<int>(int*)
foo<int*>(&j); // calls foo<int*>(int*), ok
}
|