2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / other / ptrmem2.C
blobd267df15be163dbdbef634c5e6600dc6e838847b
1 // { dg-do compile }
3 // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
4 // Contributed by Nathan Sidwell 31 Dec 2001 <nathan@codesourcery.com>
6 // PR 4379. We created pointers to member references and pointers to
7 // member fields when we shouldn't have.
9 struct D {
10   
11   int &m;       // { dg-error "invalid use of non-static data member" "" }
12   static int &s;
13   
14   int Foo ();
17 template<class T> int f1(T x);
18 template<class T> int f2(T x);
20 int D::Foo ()
22   f1( &D::m);   // { dg-error "cannot create pointer to ref" "" }
23   f1( &(D::m)); // ok
24   f2( &D::s);   // ok
25   f2( &(D::s)); // ok
26   return 0;
29 int Foo ()
31   f1( &D::m);    // { dg-error "cannot create pointer to ref" "" }
32   f1( &(D::m));  // { dg-error "from this location" "" }
33   f2( &D::s);    // ok
34   f2( &(D::s));  // ok
35   return 0;