1 // { dg-do run } 2 3 // Copyright (C) 2001 Free Software Foundation, Inc. 4 // Contributed by Nathan Sidwell 31 Dec 2001 <nathan@codesourcery.com> 5 6 // PR 4379. We created pointers to member references and pointers to 7 // member fields when we shouldn't have. 8 9 int gs; 10 int gm; 11 12 struct D { DD13 D () :m (gm) {} 14 15 int &m; 16 static int &s; 17 18 int Foo (); 19 }; 20 21 int &D::s = gs; 22 f1(T x)23template<class T> int f1(T x) 24 { 25 return x != &gm; 26 } f2(T x)27template<class T> int f2(T x) 28 { 29 return x != &gs; 30 } 31 Foo()32int D::Foo () 33 { 34 int r; 35 36 if (f1( &(D::m))) 37 return 3; 38 39 if (f2( &D::s)) 40 return 1; 41 if (f2( &(D::s))) 42 return 2; 43 return 0; 44 } 45 Foo()46int Foo () 47 { 48 if (f2( &D::s)) 49 return 4; 50 if (f2( &(D::s))) 51 return 5; 52 return 0; 53 } 54 main()55int main () 56 { 57 D d; 58 int r = d.Foo (); 59 if (r) 60 return r; 61 r = Foo (); 62 if (r) 63 return r; 64 return 0; 65 66 } 67