Sebastian Redl | f30208a | 2009-01-24 21:16:55 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
| 2 | |
| 3 | struct A {}; |
| 4 | enum B { Dummy }; |
| 5 | namespace C {} |
Sebastian Redl | 4433aaf | 2009-01-25 19:43:20 +0000 | [diff] [blame^] | 6 | struct D : A {}; |
Sebastian Redl | f30208a | 2009-01-24 21:16:55 +0000 | [diff] [blame] | 7 | |
| 8 | int A::*pdi1; |
| 9 | int (::A::*pdi2); |
| 10 | int (A::*pfi)(int); |
| 11 | |
| 12 | int B::*pbi; // expected-error {{expected a class or namespace}} |
| 13 | int C::*pci; // expected-error {{'pci' does not point into a class}} |
| 14 | void A::*pdv; // expected-error {{'pdv' declared as a member pointer to void}} |
| 15 | int& A::*pdr; // expected-error {{'pdr' declared as a pointer to a reference}} |
Sebastian Redl | 8edef7c | 2009-01-24 23:29:36 +0000 | [diff] [blame] | 16 | |
| 17 | void f() { |
| 18 | // This requires tentative parsing. |
| 19 | int (A::*pf)(int, int); |
Sebastian Redl | 4433aaf | 2009-01-25 19:43:20 +0000 | [diff] [blame^] | 20 | |
| 21 | // Implicit conversion to bool. |
| 22 | bool b = pdi1; |
| 23 | b = pfi; |
| 24 | |
| 25 | // Conversion from null pointer constant. |
| 26 | pf = 0; |
| 27 | pf = __null; |
| 28 | |
| 29 | // Conversion to member of derived. |
| 30 | int D::*pdid = pdi1; |
| 31 | pdid = pdi2; |
Sebastian Redl | 8edef7c | 2009-01-24 23:29:36 +0000 | [diff] [blame] | 32 | } |