Daniel Dunbar | a45cf5b | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
Douglas Gregor | 2eedc3a | 2008-12-20 23:49:58 +0000 | [diff] [blame] | 2 | |
| 3 | class X{ |
| 4 | public: |
| 5 | enum E {Enumerator}; |
| 6 | int f(); |
| 7 | static int mem; |
| 8 | static float g(); |
| 9 | }; |
| 10 | |
| 11 | void test(X* xp, X x) { |
| 12 | int i1 = x.f(); |
| 13 | int i2 = xp->f(); |
| 14 | x.E; // expected-error{{cannot refer to type member 'E' with '.'}} |
| 15 | xp->E; // expected-error{{cannot refer to type member 'E' with '->'}} |
Douglas Gregor | 6bd18af | 2009-01-16 03:02:29 +0000 | [diff] [blame] | 16 | int i3 = x.Enumerator; |
| 17 | int i4 = xp->Enumerator; |
Douglas Gregor | 2eedc3a | 2008-12-20 23:49:58 +0000 | [diff] [blame] | 18 | x.mem = 1; |
| 19 | xp->mem = 2; |
| 20 | float f1 = x.g(); |
| 21 | float f2 = xp->g(); |
| 22 | } |
Douglas Gregor | 0b08ba4 | 2009-03-27 06:00:30 +0000 | [diff] [blame] | 23 | |
| 24 | struct A { |
| 25 | int f0; |
| 26 | }; |
| 27 | struct B { |
| 28 | A *f0(); |
| 29 | }; |
| 30 | int f0(B *b) { |
Argyrios Kyrtzidis | b1d51aa | 2009-06-03 02:06:50 +0000 | [diff] [blame] | 31 | return b->f0->f0; // expected-error{{member reference base type 'struct A *()' is not a structure or union}} \ |
Douglas Gregor | 0b08ba4 | 2009-03-27 06:00:30 +0000 | [diff] [blame] | 32 | // expected-note{{perhaps you meant to call this function}} |
| 33 | } |
Douglas Gregor | 0b3d95a | 2009-10-17 22:37:54 +0000 | [diff] [blame^] | 34 | |
| 35 | int i; |
| 36 | |
| 37 | namespace C { |
| 38 | int i; |
| 39 | } |
| 40 | |
| 41 | void test2(X *xp) { |
| 42 | xp->::i = 7; // expected-error{{qualified member access refers to a member in the global namespace}} |
| 43 | xp->C::i = 7; // expected-error{{qualified member access refers to a member in namespace 'C'}} |
| 44 | } |