Merged r158704 through r158906 into branch.
[official-gcc.git] / gcc / testsuite / g++.dg / template / dependent-expr5.C
blobdb67273b36203c0fa0a4ddda20fbc181cdb2d4cb
1 // { dg-do compile }
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.
7 template<class F> void bind(F f) {}
9 template<class F> void bindm(F f) {}
10 template<class F, class T> void bindm(F (T::*f)(void)) {} // { dg-message "note" }
12 template<class F> void bindn(F f) {}
13 template<class F, class T> void bindn(F (*f)(T)) {}
15 template<class F> void bindb(F f) {}
16 template<class F, class T> void bindb(F (*f)(T)) {} // { dg-message "note" }
17 template<class F, class T> void bindb(F (T::*f)(void)) {} // { dg-message "note" }
19 struct foo {
20   static int baist;
21   int bait;                     // { dg-error "non-static data member" }
22   void barf ();
23   static void barf (int);
25   struct bar {
26     static int baikst;
27     int baikt;
28     void bark ();
29     static void bark (int);
31     bar() {
32       bind (&baist);
33       bind (&foo::baist);
34       bind (&bait); // { dg-error "from this location" }
35       bind (&foo::bait);
37       bind (&baikst);
38       bind (&bar::baikst);
39       bind (&baikt); // ok, this->baikt
40       bind (&bar::baikt);
42       bind (&barf); // { dg-error "no matching function" }
43       bind (&foo::barf); // { dg-error "no matching function" }
45       bindm (&barf); // { dg-error "no matching function" }
46       bindm (&foo::barf);
48       bindn (&barf);
49       bindn (&foo::barf);
51       bindb (&barf);
52       bindb (&foo::barf); // { dg-error "ambiguous" }
54       bind (&bark); // { dg-error "no matching function" }
55       bind (&bar::bark); // { dg-error "no matching function" }
57       bindm (&bark); // { dg-error "no matching function" }
58       bindm (&bar::bark);
60       bindn (&bark);
61       bindn (&bar::bark);
63       bindb (&bark);
64       bindb (&bar::bark); // { dg-error "ambiguous" }
65     }
66   };
68   template <typename T>
69   struct barT {
70     static int baikst;
71     int baikt;
72     void bark ();
73     static void bark (int);
75     barT() {
76       bind (&baist);
77       bind (&foo::baist);
78       bind (&bait); // { dg-error "from this location" }
79       bind (&foo::bait);
81       bind (&baikst);
82       bind (&barT::baikst);
83       bind (&baikt); // ok, this->baikt
84       bind (&barT::baikt);
86       bind (&barf); // { dg-error "no matching function" }
87       bind (&foo::barf); // { dg-error "no matching function" }
89       bindm (&barf); // { dg-error "no matching function" }
90       bindm (&foo::barf);
92       bindn (&barf);
93       bindn (&foo::barf);
95       bindb (&barf);
96       bindb (&foo::barf); // { dg-error "ambiguous" }
98       bind (&bark); // { dg-error "no matching function" }
99       bind (&barT::bark); // { dg-error "no matching function" }
101       bindm (&bark); // { dg-error "no matching function" }
102       bindm (&barT::bark);
104       bindn (&bark);
105       bindn (&barT::bark);
107       bindb (&bark);
108       bindb (&barT::bark); // { dg-error "ambiguous" }
109     }
110   };
112   bar bard;
113   barT<void> bart;
114 } bad;