Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x |
Fariborz Jahanian | 5de2450 | 2009-10-28 16:49:46 +0000 | [diff] [blame] | 2 | |
| 3 | struct S { |
| 4 | int i; |
| 5 | |
| 6 | int mem(int); |
| 7 | }; |
| 8 | |
| 9 | int 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 Kyrtzidis | 0f279e7 | 2010-10-30 19:52:22 +0000 | [diff] [blame] | 14 | struct S2 { |
| 15 | int bitfield : 1; |
| 16 | }; |
| 17 | |
| 18 | int S2::*pf = &S2::bitfield; // expected-error {{address of bit-field requested}} |
Argyrios Kyrtzidis | 11ab790 | 2010-11-01 18:49:26 +0000 | [diff] [blame^] | 19 | |
| 20 | struct S3 { |
| 21 | void m(); |
| 22 | }; |
| 23 | |
| 24 | void 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 | } |