1// { dg-do assemble } 2 3class foo_a { 4 protected: 5 double func(int xi) {return 0.0;} 6 public: 7 foo_a() {} 8}; 9 10class foo_b { 11 public: 12 foo_b(int); 13 foo_b(); 14 ~foo_b(); 15 foo_b(const foo_b&); 16 double& operator()(int); 17 foo_b& operator=(foo_b&); 18 void bar_a(int); 19}; 20 21foo_b& operator*(foo_b&, foo_b&); 22foo_b& operator*(double, foo_b&); 23 24template <class TP> 25class foo_c { 26 typedef double (TP::* Tmatf)(int); 27 int m; 28 Tmatf* a; 29 void foo_cinst (int mm); 30 public: 31 foo_c(int mm); 32 foo_c() {m = 0; a = 0;} 33 ~foo_c() {delete a;} 34 double (TP::*& operator()(int i))(int) {return a[i];} 35 foo_b& bug_func(int); 36}; 37 38template <class TP> 39foo_b& foo_c<TP>::bug_func(int x) { 40 static foo_b retval(m); 41 retval.bar_a(m); 42 for (register int i = 0; i < m; i++) 43 retval(i) = (*(operator()(i)))(x); // { dg-error "" } 44 return retval; 45} 46 47template <class TP> 48class foo_d { 49 protected: 50 foo_c<TP> bar_b; 51 public: 52 foo_d() {} 53 virtual ~foo_d() {} 54 virtual void setfoo_c(); 55}; 56 57class foo_e : public foo_a, public foo_d<foo_a> { 58 public: 59 foo_e(); 60 ~foo_e() {} 61 void setfoo_c(); 62}; 63 64void foo_e::setfoo_c() { 65 bar_b(0) = func; // { dg-error "" } 66} 67 68template class foo_c<foo_a>; 69