| 1 |
// { dg-do compile } |
| 2 |
|
| 3 |
// Copyright (C) 2001, 2002 Free Software Foundation, Inc. |
| 4 |
// Contributed by Nathan Sidwell 31 Dec 2001 <[email protected]> |
| 5 |
|
| 6 |
// PR 4379. We created pointers to member references and pointers to |
| 7 |
// member fields when we shouldn't have. |
| 8 |
|
| 9 |
struct D { |
| 10 |
|
| 11 |
int &m; // { dg-message "" } |
| 12 |
static int &s; |
| 13 |
|
| 14 |
int Foo (); |
| 15 |
}; |
| 16 |
|
| 17 |
template<class T> int f1(T x); |
| 18 |
template<class T> int f2(T x); |
| 19 |
|
| 20 |
int D::Foo () |
| 21 |
{ |
| 22 |
f1( &D::m); // { dg-error "11:cannot create pointer to ref" } |
| 23 |
f1( &(D::m)); // ok |
| 24 |
f2( &D::s); // ok |
| 25 |
f2( &(D::s)); // ok |
| 26 |
return 0; |
| 27 |
} |
| 28 |
|
| 29 |
int Foo () |
| 30 |
{ |
| 31 |
f1( &D::m); // { dg-error "11:cannot create pointer to ref" } |
| 32 |
f1( &(D::m)); // { dg-error "non-static" } |
| 33 |
f2( &D::s); // ok |
| 34 |
f2( &(D::s)); // ok |
| 35 |
return 0; |
| 36 |
} |