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