summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.other/ptrmem7.C
blob: b04f7e2657c48a4567f4d2dfd792031842413c04 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// { dg-do assemble  }
// 
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 14 Aug 2000 <nathan@codesourcery.com>

// A pointer to member can only be formed by `&T::m', however, other forms
// are ok for pointer to static member. Thus the error can only be determined
// after overload resolution.

struct A
{
  static int ns (short);
  static int ns (float);
  int ns (int);
  int ns (double);
  int single (int);
  static int sole (short);
  void foo ();
};
void A::foo ()
{
  int (A::*ptr1) (int) = &A::ns;
  int (A::*ptr2) (int) = A::ns;           // { dg-error "pointer to member" "err" }
  // { dg-message "pointer to member" "note" { target *-*-* } 23 }
  int (A::*ptr3) (int) = &ns;             // { dg-error "pointer to member" "err" }
  int (A::*ptr4) (int) = ns;              // { dg-error "pointer to member" "err" }

  int (*ptr5) (short) = &A::ns;
  int (*ptr6) (short) = A::ns;
  int (*ptr7) (short) = &ns;
  int (*ptr8) (short) = ns;

  int (A::*ptr11) (int) = &A::single;
  int (A::*ptr12) (int) = A::single;      // { dg-error "match" }
  int (A::*ptr13) (int) = &single;        // { dg-error "pointer to member" }
  int (A::*ptr14) (int) = single;         // { dg-error "match" }

  int (A::*ptr20) (int) = &(A::ns);       // { dg-error "pointer to member" }
  int (A::*ptr21) (int) = &(A::single);   // { dg-error "pointer to member" }

  int (*ptr31) (short) = &A::sole;
  int (*ptr32) (short) = A::sole;
  int (*ptr33) (short) = &sole;
  int (*ptr34) (short) = sole;
  int (*ptr41) (short) = &(A::sole);
  int (*ptr43) (short) = &(sole);
}