1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
namespace A
{
namespace B
{
struct base
#if __cplusplus <= 199711L
// expected-note@-2 {{lookup in the object type 'A::sub' refers here}}
#endif
{
void x() {}
void y() {}
};
}
struct member
{
void foo();
};
struct middleman
{
member * operator->() { return 0; }
};
struct sub : B::base
{
void x() {}
middleman operator->() { return middleman(); }
};
}
struct bad
{
int x();
};
namespace C
{
void fun()
{
A::sub a;
a.x();
a.sub::x();
a.base::x();
a.B::base::x(); // expected-error{{use of undeclared identifier 'B'}}
a.A::sub::x();
a.A::B::base::x();
a.bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}}
a->foo();
a->member::foo();
a->A::member::foo();
}
void fun2()
{
A::sub *a;
a->x();
a->sub::x();
a->base::x();
a->B::base::x(); // expected-error{{use of undeclared identifier 'B'}}
a->A::sub::x();
a->A::B::base::x();
a->bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}}
(*a)->foo();
(*a)->member::foo();
(*a)->A::member::foo();
}
void fun3()
{
int i;
i.foo(); // expected-error{{member reference base type 'int' is not a structure or union}}
}
void fun4a() {
A::sub *a;
typedef A::member base;
#if __cplusplus <= 199711L
// expected-note@-2 {{lookup from the current scope refers here}}
#endif
a->base::x();
#if __cplusplus <= 199711L
// expected-error@-2 {{lookup of 'base' in member access expression is ambiguous}}
#endif
}
void fun4b() {
A::sub *a;
typedef A::B::base base;
a->base::x();
}
template<typename T>
void fun5()
{
T a;
a.x();
a->foo();
a.A::sub::x();
a.A::B::base::x();
a->A::member::foo();
a.bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}}
}
void test_fun5() {
fun5<A::sub>(); // expected-note{{instantiation}}
}
template<typename T>
void fun6() {
T a;
a.sub::x();
a.base::x();
a->member::foo();
a.B::base::x(); // expected-error{{use of undeclared identifier 'B'}}
}
void test_fun6() {
fun6<A::sub>(); // expected-note{{instantiation}}
}
}
// PR4703
struct a {
int a;
static int sa;
};
a a;
int a::sa = a.a; // expected-error {{invalid use of non-static data member 'a'}}
namespace PR6645 {
typedef int foo;
namespace Inner {
typedef int PR6645::foo; // expected-error{{typedef declarator cannot be qualified}} \
// expected-error{{cannot define or redeclare 'foo' here because namespace 'Inner' does not enclose namespace 'PR6645'}}
}
}
|