Richard Smith | 9ca5c42 | 2011-10-13 22:29:44 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 |
Fariborz Jahanian | 42f6663 | 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 | d3f0054 | 2010-10-30 19:52:22 +0000 | [diff] [blame] | 14 | struct S2 { |
| 15 | int bitfield : 1; |
Richard Smith | cf68126 | 2017-04-13 21:49:46 +0000 | [diff] [blame] | 16 | struct { |
| 17 | int anon_bitfield : 1; |
| 18 | }; |
Argyrios Kyrtzidis | d3f0054 | 2010-10-30 19:52:22 +0000 | [diff] [blame] | 19 | }; |
| 20 | |
| 21 | int S2::*pf = &S2::bitfield; // expected-error {{address of bit-field requested}} |
Richard Smith | cf68126 | 2017-04-13 21:49:46 +0000 | [diff] [blame] | 22 | int S2::*anon_pf = &S2::anon_bitfield; // expected-error {{address of bit-field requested}} |
Argyrios Kyrtzidis | ca76629 | 2010-11-01 18:49:26 +0000 | [diff] [blame] | 23 | |
| 24 | struct S3 { |
| 25 | void m(); |
| 26 | }; |
| 27 | |
| 28 | void f3(S3* p, void (S3::*m)()) { |
John McCall | 50a2c2c | 2011-10-11 23:14:30 +0000 | [diff] [blame] | 29 | p->*m; // expected-error {{reference to non-static member function must be called}} |
| 30 | (void)(p->*m); // expected-error {{reference to non-static member function must be called}} |
| 31 | (void)(void*)(p->*m); // expected-error {{reference to non-static member function must be called}} expected-error {{cannot cast from type 'void' to pointer type 'void *'}} |
| 32 | (void)reinterpret_cast<void*>(p->*m); // expected-error {{reference to non-static member function must be called}} expected-error {{reinterpret_cast from 'void' to 'void *' is not allowed}} |
| 33 | if (p->*m) {} // expected-error {{reference to non-static member function must be called}} expected-error {{value of type 'void' is not contextually convertible to 'bool'}} |
| 34 | if (!(p->*m)) {} // expected-error {{reference to non-static member function must be called}} expected-error {{invalid argument type 'void' to unary expression}} |
| 35 | if (p->m) {}; // expected-error {{reference to non-static member function must be called}} expected-error {{value of type 'void' is not contextually convertible to 'bool'}} |
| 36 | if (!p->m) {}; // expected-error {{reference to non-static member function must be called}} expected-error {{invalid argument type 'void' to unary expression}} |
Argyrios Kyrtzidis | ca76629 | 2010-11-01 18:49:26 +0000 | [diff] [blame] | 37 | } |