1// RUN: %clang_cc1 -emit-llvm-only %s
2
3// Tests that Sema properly creates member-access expressions for
4// these instead of bare FieldDecls.
5
6struct Foo {
7  int myvalue;
8
9  // We have to override these to get something with an lvalue result.
10  int &operator++(int);
11  int &operator--(int);
12};
13
14struct Test0 {
15  Foo memfoo;
16  int memint;
17  int memarr[10];
18  Test0 *memptr;
19  struct MemClass { int a; } memstruct;
20  int &memfun();
21
22  void test() {
23    int *p;
24    p = &Test0::memfoo++;
25    p = &Test0::memfoo--;
26    p = &Test0::memarr[1];
27    p = &Test0::memptr->memint;
28    p = &Test0::memstruct.a;
29    p = &Test0::memfun();
30  }
31};
32
33void test0() {
34  Test0 mytest;
35  mytest.test();
36}
37
38namespace rdar9065289 {
39  typedef void (*FuncPtr)();
40  struct X0 { };
41
42  struct X1
43  {
44    X0* x0;
45    FuncPtr X0::*fptr;
46  };
47
48  void f(X1 p) {
49    (p.x0->*(p.fptr))();
50  }
51}
52