blob: f26f13f19cd30ffab0d25320563951a6c8d2fd67 [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)()) {
25 p->*m; // expected-error {{a bound member function may only be used to call it}}
26 (void)(p->*m); // expected-error {{a bound member function may only be used to call it}}
27 (void)(void*)(p->*m); // expected-error {{a bound member function may only be used to call it}}
28 (void)reinterpret_cast<void*>(p->*m); // expected-error {{a bound member function may only be used to call it}}
29 if (p->*m) {} // expected-error {{a bound member function may only be used to call it}}
30
31 p->m; // expected-error {{a bound member function may only be used to call it}}
32}