blob: 8afcb112a36b55be0f301d6a13437e505507bba9 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x
Fariborz Jahanian5de24502009-10-28 16:49:46 +00002
3struct S {
4 int i;
5
6 int mem(int);
7};
8
9int foo(int S::* ps, S *s)
10{
11 return (s->*ps)(1); // expected-error {{called object type 'int' is not a function or function pointer}}
12}
13
Argyrios Kyrtzidis0f279e72010-10-30 19:52:22 +000014struct S2 {
15 int bitfield : 1;
16};
17
18int S2::*pf = &S2::bitfield; // expected-error {{address of bit-field requested}}
Argyrios Kyrtzidis11ab7902010-11-01 18:49:26 +000019
20struct S3 {
21 void m();
22};
23
24void f3(S3* p, void (S3::*m)()) {
Chandler Carruth914c9a62011-01-06 06:29:28 +000025 p->*m; // expected-error {{a bound member function may only be called}}
26 (void)(p->*m); // expected-error {{a bound member function may only be called}}
27 (void)(void*)(p->*m); // expected-error {{a bound member function may only be called}}
28 (void)reinterpret_cast<void*>(p->*m); // expected-error {{a bound member function may only be called}}
29 if (p->*m) {} // expected-error {{a bound member function may only be called}}
Douglas Gregorbec73432011-03-23 21:19:43 +000030 if (!p->*m) {} // FIXME: xpected-error {{a bound member function may only be called}} \
31 // expected-error{{left hand operand to ->* must be a pointer to class compatible with the right hand operand, but is 'bool'}}
Marshall Clow31798a62011-03-23 19:44:36 +000032 if (p->m) {}; // expected-error {{a bound member function may only be called}}
Douglas Gregorbec73432011-03-23 21:19:43 +000033 if (!p->m) {}; // FIXME: xpected-error {{a bound member function may only be called}}
Argyrios Kyrtzidis11ab7902010-11-01 18:49:26 +000034}