1// { dg-do compile }
2
3// Copyright 2005 Free Software Foundation
4// contributed by Alexandre Oliva <aoliva@redhat.com>
5// inspired in the failure reported in Red Hat bugzilla #168260.
6
7template<class F> void bind(F f) {}
8
9template<class F> void bindm(F f) {}
10template<class F, class T> void bindm(F (T::*f)(void)) {} // { dg-message "note" }
11
12template<class F> void bindn(F f) {}
13template<class F, class T> void bindn(F (*f)(T)) {}
14
15template<class F> void bindb(F f) {}
16template<class F, class T> void bindb(F (*f)(T)) {} // { dg-message "note" }
17template<class F, class T> void bindb(F (T::*f)(void)) {} // { dg-message "note" }
18
19struct foo {
20  static int baist;
21  int bait;
22  void barf ();
23  static void barf (int);
24
25  struct bar {
26    static int baikst;
27    int baikt;
28    void bark ();
29    static void bark (int);
30
31    bar() {
32      bind (&baist);
33      bind (&foo::baist);
34      bind (&bait); // { dg-error "nonstatic data member" }
35      bind (&foo::bait);
36
37      bind (&baikst);
38      bind (&bar::baikst);
39      bind (&baikt); // ok, this->baikt
40      bind (&bar::baikt);
41
42      bind (&barf); // { dg-error "no matching function" }
43      bind (&foo::barf); // { dg-error "no matching function" }
44
45      bindm (&barf); // { dg-error "no matching function" }
46      bindm (&foo::barf);
47
48      bindn (&barf);
49      bindn (&foo::barf);
50
51      bindb (&barf);
52      bindb (&foo::barf); // { dg-error "ambiguous" }
53
54      bind (&bark); // { dg-error "no matching function" }
55      bind (&bar::bark); // { dg-error "no matching function" }
56
57      bindm (&bark); // { dg-error "no matching function" }
58      bindm (&bar::bark);
59
60      bindn (&bark);
61      bindn (&bar::bark);
62
63      bindb (&bark);
64      bindb (&bar::bark); // { dg-error "ambiguous" }
65    }
66  };
67
68  template <typename T>
69  struct barT {
70    static int baikst;
71    int baikt;
72    void bark ();
73    static void bark (int);
74
75    barT() {
76      bind (&baist);
77      bind (&foo::baist);
78      bind (&bait); // { dg-error "nonstatic data member" }
79      bind (&foo::bait);
80
81      bind (&baikst);
82      bind (&barT::baikst);
83      bind (&baikt); // ok, this->baikt
84      bind (&barT::baikt);
85
86      bind (&barf); // { dg-error "no matching function" }
87      bind (&foo::barf); // { dg-error "no matching function" }
88
89      bindm (&barf); // { dg-error "no matching function" }
90      bindm (&foo::barf);
91
92      bindn (&barf);
93      bindn (&foo::barf);
94
95      bindb (&barf);
96      bindb (&foo::barf); // { dg-error "ambiguous" }
97
98      bind (&bark); // { dg-error "no matching function" }
99      bind (&barT::bark); // { dg-error "no matching function" }
100
101      bindm (&bark); // { dg-error "no matching function" }
102      bindm (&barT::bark);
103
104      bindn (&bark);
105      bindn (&barT::bark);
106
107      bindb (&bark);
108      bindb (&barT::bark); // { dg-error "ambiguous" }
109    }
110  };
111
112  bar bard;
113  barT<void> bart;
114} bad;
115