blob: 9cd6855ccd55300016628b6db0c69a47ba58eaf7 [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify %s
Douglas Gregor86f19402008-12-20 23:49:58 +00002
3class X{
4public:
5 enum E {Enumerator};
6 int f();
7 static int mem;
8 static float g();
9};
10
11void 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 Gregor76f7d282009-01-16 03:02:29 +000016 int i3 = x.Enumerator;
17 int i4 = xp->Enumerator;
Douglas Gregor86f19402008-12-20 23:49:58 +000018 x.mem = 1;
19 xp->mem = 2;
20 float f1 = x.g();
21 float f2 = xp->g();
22}
Douglas Gregor214f31a2009-03-27 06:00:30 +000023
24struct A {
25 int f0;
26};
27struct B {
28 A *f0();
29};
30int f0(B *b) {
Douglas Gregor3f0b5fd2009-11-06 06:30:47 +000031 return b->f0->f0; // expected-error{{perhaps you meant to call this function}}
Douglas Gregor214f31a2009-03-27 06:00:30 +000032}
Douglas Gregor8d1c9ae2009-10-17 22:37:54 +000033
34int i;
35
36namespace C {
37 int i;
38}
39
40void test2(X *xp) {
41 xp->::i = 7; // expected-error{{qualified member access refers to a member in the global namespace}}
42 xp->C::i = 7; // expected-error{{qualified member access refers to a member in namespace 'C'}}
43}
John McCallb1b42562009-12-01 22:28:41 +000044
45
46namespace test3 {
47 struct NamespaceDecl;
48
49 struct NamedDecl {
50 void *getIdentifier() const;
51 };
52
53 struct NamespaceDecl : NamedDecl {
54 bool isAnonymousNamespace() const {
55 return !getIdentifier();
56 }
57 };
58}