blob: c3917333a540b4564d7475fca152dfdd78e8cb96 [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}}
John McCall864c0412011-04-26 20:42:42 +000030 if (!(p->*m)) {} // expected-error {{a bound member function may only be called}}
Marshall Clow31798a62011-03-23 19:44:36 +000031 if (p->m) {}; // expected-error {{a bound member function may only be called}}
John McCall864c0412011-04-26 20:42:42 +000032 if (!p->m) {}; // expected-error {{a bound member function may only be called}}
Argyrios Kyrtzidis11ab7902010-11-01 18:49:26 +000033}