member-expr.cpp revision 214f31a347d7824eb92e6a3f5dce4d4047fd5ae0
1d7d5f0223bd30dfd618762349c6209dd1d5ea3e6Daniel Dunbar// RUN: clang-cc -fsyntax-only -verify %s 286f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor 386f194083504938df72135b5b66bf0c5cafd9498Douglas Gregorclass X{ 486f194083504938df72135b5b66bf0c5cafd9498Douglas Gregorpublic: 586f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor enum E {Enumerator}; 686f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor int f(); 786f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor static int mem; 886f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor static float g(); 986f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor}; 1086f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor 1186f194083504938df72135b5b66bf0c5cafd9498Douglas Gregorvoid test(X* xp, X x) { 1286f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor int i1 = x.f(); 1386f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor int i2 = xp->f(); 1486f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor x.E; // expected-error{{cannot refer to type member 'E' with '.'}} 1586f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor xp->E; // expected-error{{cannot refer to type member 'E' with '->'}} 1676f7d287020a0b4996d6e9d3968d5bd9a39f7d84Douglas Gregor int i3 = x.Enumerator; 1776f7d287020a0b4996d6e9d3968d5bd9a39f7d84Douglas Gregor int i4 = xp->Enumerator; 1886f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor x.mem = 1; 1986f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor xp->mem = 2; 2086f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor float f1 = x.g(); 2186f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor float f2 = xp->g(); 2286f194083504938df72135b5b66bf0c5cafd9498Douglas Gregor} 23214f31a347d7824eb92e6a3f5dce4d4047fd5ae0Douglas Gregor 24214f31a347d7824eb92e6a3f5dce4d4047fd5ae0Douglas Gregorstruct A { 25214f31a347d7824eb92e6a3f5dce4d4047fd5ae0Douglas Gregor int f0; 26214f31a347d7824eb92e6a3f5dce4d4047fd5ae0Douglas Gregor}; 27214f31a347d7824eb92e6a3f5dce4d4047fd5ae0Douglas Gregorstruct B { 28214f31a347d7824eb92e6a3f5dce4d4047fd5ae0Douglas Gregor A *f0(); 29214f31a347d7824eb92e6a3f5dce4d4047fd5ae0Douglas Gregor}; 30214f31a347d7824eb92e6a3f5dce4d4047fd5ae0Douglas Gregorint f0(B *b) { 31214f31a347d7824eb92e6a3f5dce4d4047fd5ae0Douglas Gregor return b->f0->f0; // expected-error{{member reference base type 'struct A *(void)' is not a structure or union}} \ 32214f31a347d7824eb92e6a3f5dce4d4047fd5ae0Douglas Gregor // expected-note{{perhaps you meant to call this function}} 33214f31a347d7824eb92e6a3f5dce4d4047fd5ae0Douglas Gregor} 34