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