summaryrefslogtreecommitdiff
path: root/clang/test/CXX/basic/basic.lookup
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CXX/basic/basic.lookup')
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp27
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp110
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp20
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp64
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp89
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p3.cpp30
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp60
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp18
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp27
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp65
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp41
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp25
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp35
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6-0x.cpp26
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp24
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp35
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p11.cpp12
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p12.cpp13
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p13.cpp8
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp18
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p15.cpp17
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp24
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp37
23 files changed, 825 insertions, 0 deletions
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp
new file mode 100644
index 0000000..f650ad5
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace N1 {
+ struct X { };
+ int& f(void*);
+}
+
+namespace N2 {
+ template<typename T> struct Y { };
+}
+
+namespace N3 {
+ void test() {
+ int &ir = f((N2::Y<N1::X>*)0);
+ }
+}
+
+int g(void *);
+long g(N1::X);
+
+namespace N1 {
+ void h(int (*)(void *));
+}
+
+void test() {
+ h((&g));
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp
new file mode 100644
index 0000000..f5ad68b
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace N {
+ struct X { };
+
+ X operator+(X, X);
+
+ void f(X);
+ void g(X); // expected-note{{candidate function}}
+
+ void test_multiadd(X x) {
+ (void)(x + x);
+ }
+}
+
+namespace M {
+ struct Y : N::X { };
+}
+
+void f(); // expected-note 2 {{'f' declared here}}
+
+void test_operator_adl(N::X x, M::Y y) {
+ (void)(x + x);
+ (void)(y + y);
+}
+
+void test_func_adl(N::X x, M::Y y) {
+ f(x);
+ f(y);
+ (f)(x); // expected-error{{too many arguments to function call}}
+ ::f(x); // expected-error{{too many arguments to function call}}
+}
+
+namespace N {
+ void test_multiadd2(X x) {
+ (void)(x + x);
+ }
+}
+
+
+void test_func_adl_only(N::X x) {
+ g(x);
+}
+
+namespace M {
+ int g(N::X); // expected-note{{candidate function}}
+
+ void test(N::X x) {
+ g(x); // expected-error{{call to 'g' is ambiguous}}
+ int i = (g)(x);
+
+ int g(N::X);
+ g(x); // okay; calls locally-declared function, no ADL
+ }
+}
+
+
+void test_operator_name_adl(N::X x) {
+ (void)operator+(x, x);
+}
+
+struct Z { };
+int& f(Z);
+
+namespace O {
+ char &f();
+ void test_global_scope_adl(Z z) {
+ {
+ int& ir = f(z);
+ }
+ }
+}
+
+extern "C" {
+ struct L { };
+}
+
+void h(L); // expected-note{{candidate function}}
+
+namespace P {
+ void h(L); // expected-note{{candidate function}}
+ void test_transparent_context_adl(L l) {
+ {
+ h(l); // expected-error {{call to 'h' is ambiguous}}
+ }
+ }
+}
+
+namespace test5 {
+ namespace NS {
+ struct A;
+ void foo(void (*)(A&));
+ }
+ void bar(NS::A& a);
+
+ void test() {
+ foo(&bar);
+ }
+}
+
+// PR6762: __builtin_va_list should be invisible to ADL on all platforms.
+void test6_function(__builtin_va_list &argv);
+namespace test6 {
+ void test6_function(__builtin_va_list &argv);
+
+ void test() {
+ __builtin_va_list args;
+ test6_function(args);
+ }
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp
new file mode 100644
index 0000000..c4c2c8d
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// FIXME: embellish
+
+namespace test0 {
+ namespace A {
+ class Foo {
+ };
+
+ void foo(const Foo &foo);
+ }
+
+ class Test {
+ enum E { foo = 0 };
+
+ void test() {
+ foo(A::Foo()); // expected-error {{not a function}}
+ }
+ };
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
new file mode 100644
index 0000000..32dd75a
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace A {
+ class A {
+ friend void func(A);
+ friend A operator+(A,A);
+ };
+}
+
+namespace B {
+ class B {
+ static void func(B);
+ };
+ B operator+(B,B);
+}
+
+namespace D {
+ class D {};
+}
+
+namespace C {
+ class C {}; // expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'B::B' to 'const C::C &' for 1st argument}}
+ void func(C); // expected-note {{'C::func' declared here}} \
+ // expected-note {{passing argument to parameter here}}
+ C operator+(C,C);
+ D::D operator+(D::D,D::D);
+}
+
+namespace D {
+ using namespace C;
+}
+
+namespace Test {
+ void test() {
+ func(A::A());
+ // FIXME: namespace-aware typo correction causes an extra, misleading
+ // message in this case; some form of backtracking, diagnostic message
+ // delaying, or argument checking before emitting diagnostics is needed to
+ // avoid accepting and printing out a typo correction that proves to be
+ // incorrect once argument-dependent lookup resolution has occurred.
+ func(B::B()); // expected-error {{use of undeclared identifier 'func'; did you mean 'C::func'?}} \
+ // expected-error {{no viable conversion from 'B::B' to 'C::C'}}
+ func(C::C());
+ A::A() + A::A();
+ B::B() + B::B();
+ C::C() + C::C();
+ D::D() + D::D(); // expected-error {{invalid operands to binary expression ('D::D' and 'D::D')}}
+ }
+}
+
+// PR6716
+namespace test1 {
+ template <class T> class A {
+ template <class U> friend void foo(A &, U); // expected-note {{not viable: 1st argument ('const A<int>') would lose const qualifier}}
+
+ public:
+ A();
+ };
+
+ void test() {
+ const A<int> a;
+ foo(a, 10); // expected-error {{no matching function for call to 'foo'}}
+ }
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
new file mode 100644
index 0000000..c207283
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify %s
+
+// C++98 [basic.lookup.classref]p1:
+// In a class member access expression (5.2.5), if the . or -> token is
+// immediately followed by an identifier followed by a <, the identifier must
+// be looked up to determine whether the < is the beginning of a template
+// argument list (14.2) or a less-than operator. The identifier is first
+// looked up in the class of the object expression. If the identifier is not
+// found, it is then looked up in the context of the entire postfix-expression
+// and shall name a class or function template. If the lookup in the class of
+// the object expression finds a template, the name is also looked up in the
+// context of the entire postfix-expression and
+// -- if the name is not found, the name found in the class of the object
+// expression is used, otherwise
+// -- if the name is found in the context of the entire postfix-expression
+// and does not name a class template, the name found in the class of the
+// object expression is used, otherwise
+// -- if the name found is a class template, it must refer to the same
+// entity as the one found in the class of the object expression,
+// otherwise the program is ill-formed.
+
+// From PR 7247
+template<typename T>
+struct set{}; // expected-note{{lookup from the current scope refers here}}
+struct Value {
+ template<typename T>
+ void set(T value) {} // expected-note{{lookup in the object type 'Value' refers here}}
+
+ void resolves_to_same() {
+ Value v;
+ v.set<double>(3.2);
+ }
+};
+void resolves_to_different() {
+ {
+ Value v;
+ // The fact that the next line is a warning rather than an error is an
+ // extension.
+ v.set<double>(3.2); // expected-warning{{lookup of 'set' in member access expression is ambiguous; using member of 'Value'}}
+ }
+ {
+ int set; // Non-template.
+ Value v;
+ v.set<double>(3.2);
+ }
+}
+
+namespace rdar9915664 {
+ struct A {
+ template<typename T> void a();
+ };
+
+ struct B : A { };
+
+ struct C : A { };
+
+ struct D : B, C {
+ A &getA() { return static_cast<B&>(*this); }
+
+ void test_a() {
+ getA().a<int>();
+ }
+ };
+}
+
+namespace PR11856 {
+ template<typename T> T end(T);
+
+ template <typename T>
+ void Foo() {
+ T it1;
+ if (it1->end < it1->end) {
+ }
+ }
+
+ template<typename T> T *end(T*);
+
+ class X { };
+ template <typename T>
+ void Foo2() {
+ T it1;
+ if (it1->end < it1->end) {
+ }
+
+ X *x;
+ if (x->end < 7) { // expected-error{{no member named 'end' in 'PR11856::X'}}
+ }
+ }
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p3.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p3.cpp
new file mode 100644
index 0000000..cd7e669
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p3.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++0x [basic.lookup.classref]p3:
+// If the unqualified-id is ~type-name, the type-name is looked up in the
+// context of the entire postfix-expression. If the type T of the object
+// expression is of a class type C, the type-name is also looked up in the
+// scope of class C. At least one of the lookups shall find a name that
+// refers to (possibly cv-qualified) T.
+
+// From core issue 305
+struct A {
+};
+
+struct C {
+ struct A {};
+ void f ();
+};
+
+void C::f () {
+ ::A *a;
+ a->~A ();
+}
+
+// From core issue 414
+struct X {};
+void f() {
+ X x;
+ struct X {};
+ x.~X();
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp
new file mode 100644
index 0000000..004d1e4
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace test0 {
+ struct A {
+ static int foo;
+ };
+
+ namespace i0 {
+ typedef int A; // expected-note {{declared here}}
+
+ int test() {
+ struct A a; // expected-error {{elaborated type refers to a typedef}}
+ return a.foo;
+ }
+ }
+
+ namespace i1 {
+ template <class> class A; // expected-note {{declared here}}
+
+ int test() {
+ struct A a; // expected-error {{elaborated type refers to a template}}
+ return a.foo;
+ }
+ }
+
+ namespace i2 {
+ int A;
+
+ int test() {
+ struct A a;
+ return a.foo;
+ }
+ }
+
+ namespace i3 {
+ void A();
+
+ int test() {
+ struct A a;
+ return a.foo;
+ }
+ }
+
+ namespace i4 {
+ template <class T> void A();
+
+ int test() {
+ struct A a;
+ return a.foo;
+ }
+ }
+
+ // This should magically be okay; see comment in SemaDecl.cpp.
+ // rdar://problem/7898108
+ typedef struct A A;
+ int test() {
+ struct A a;
+ return a.foo;
+ }
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp
new file mode 100644
index 0000000..8126d28
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// elaborated-type-specifier:
+// class-key '::'? nested-name-specifier? 'template'? simple-template-id
+// Tests that this form is accepted by the compiler but does not follow
+// the elaborated lookup rules of [basic.lookup.elab].
+
+template <typename> class Ident {}; // expected-note {{previous use is here}}
+
+namespace A {
+ template <typename> void Ident();
+
+ class Ident<int> AIdent; // expected-error {{refers to a function template}}
+ class ::Ident<int> AnotherIdent;
+}
+
+class Ident<int> GlobalIdent;
+union Ident<int> GlobalIdent2; // expected-error {{ tag type that does not match }}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
new file mode 100644
index 0000000..7ecedd5
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct X0 {
+ X0 f1();
+ X0 f2();
+};
+
+template<typename T>
+struct X1 {
+ X1<T>(int);
+ (X1<T>)(float);
+ X1 f2();
+ X1 f2(int);
+ X1 f2(float);
+};
+
+// Error recovery: out-of-line constructors whose names have template arguments.
+template<typename T> X1<T>::X1<T>(int) { } // expected-error{{out-of-line constructor for 'X1' cannot have template arguments}}
+template<typename T> (X1<T>::X1<T>)(float) { } // expected-error{{out-of-line constructor for 'X1' cannot have template arguments}}
+
+// Error recovery: out-of-line constructor names intended to be types
+X0::X0 X0::f1() { return X0(); } // expected-error{{qualified reference to 'X0' is a constructor name rather than a type wherever a constructor can be declared}}
+
+struct X0::X0 X0::f2() { return X0(); }
+
+template<typename T> X1<T>::X1<T> X1<T>::f2() { } // expected-error{{qualified reference to 'X1' is a constructor name rather than a template name wherever a constructor can be declared}}
+template<typename T> X1<T>::X1<T> (X1<T>::f2)(int) { } // expected-error{{qualified reference to 'X1' is a constructor name rather than a template name wherever a constructor can be declared}}
+template<typename T> struct X1<T>::X1<T> (X1<T>::f2)(float) { }
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
new file mode 100644
index 0000000..3039396
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace Ints {
+ int zero = 0; // expected-note {{candidate found by name lookup is 'Ints::zero'}}
+ void f(int); // expected-note 3 {{candidate function}}
+ void g(int);
+}
+
+namespace Floats {
+ float zero = 0.0f; // expected-note {{candidate found by name lookup is 'Floats::zero'}}
+ void f(float); // expected-note 3 {{candidate function}}
+ void g(float);
+}
+
+namespace Numbers {
+ using namespace Ints;
+ using namespace Floats;
+}
+
+void test() {
+ int i = Ints::zero;
+ Ints::f(i);
+
+ float f = Floats::zero;
+ Floats::f(f);
+
+ double n = Numbers::zero; // expected-error {{reference to 'zero' is ambiguous}}
+ Numbers::f(n); // expected-error{{call to 'f' is ambiguous}}
+ Numbers::f(i);
+ Numbers::f(f);
+}
+
+namespace Numbers {
+ struct Number { // expected-note 2 {{candidate}}
+ explicit Number(double d) : d(d) {}
+ double d;
+ };
+ Number zero(0.0f);
+ void g(Number); // expected-note 2{{passing argument to parameter here}}
+}
+
+void test2() {
+ Numbers::Number n = Numbers::zero;
+ Numbers::f(n); // expected-error {{no matching function for call to 'f'}}
+ Numbers::g(n);
+}
+
+namespace Numbers2 {
+ using Numbers::f;
+ using Numbers::g;
+}
+
+void test3() {
+ Numbers::Number n = Numbers::zero;
+ Numbers2::f(n); // expected-error {{no matching function for call to 'f'}}
+ Numbers2::g(n);
+
+ int i = Ints::zero;
+ Numbers2::f(i);
+ Numbers2::g(i); // expected-error {{no viable conversion from 'int' to 'Numbers::Number'}}
+
+ float f = Floats::zero;
+ Numbers2::f(f);
+ Numbers2::g(f); // expected-error {{no viable conversion from 'float' to 'Numbers::Number'}}
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp
new file mode 100644
index 0000000..dc0f8b4
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// This is basically paraphrased from the standard.
+
+namespace Root {
+ int i = 0;
+ void f();
+}
+
+namespace A {
+ using namespace Root;
+}
+
+namespace B {
+ using namespace Root;
+}
+
+namespace AB {
+ using namespace A;
+ using namespace B;
+}
+
+void test() {
+ if (AB::i)
+ AB::f();
+}
+
+namespace C {
+ using Root::i;
+ using Root::f;
+}
+
+namespace AC {
+ using namespace A;
+ using namespace C;
+}
+
+void test2() {
+ if (AC::i)
+ AC::f();
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp
new file mode 100644
index 0000000..38eccfa
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace A {
+ int a;
+}
+
+namespace C {
+ int c;
+}
+
+namespace B {
+ using namespace C;
+ int b;
+}
+
+namespace C {
+ using namespace B;
+ using namespace A;
+}
+
+void test() {
+ C::a++;
+ C::b++;
+ C::c++;
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp
new file mode 100644
index 0000000..5045bac
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace A {
+ struct x {}; // expected-note {{candidate found by name lookup is 'A::x'}}
+ int x; // expected-note {{candidate found by name lookup is 'A::x'}}
+
+ struct y {}; // expected-note {{type declaration hidden}}
+
+ struct z;
+ void z(float);
+}
+
+namespace B {
+ struct x {}; // expected-note {{candidate found by name lookup is 'B::x'}}
+ float x; // expected-note {{candidate found by name lookup is 'B::x'}}
+
+ float y; // expected-note {{declaration hides type}}
+
+ void z(int);
+}
+
+namespace AB {
+ using namespace A;
+ using namespace B;
+}
+
+void test() {
+ struct AB::x foo; // expected-error {{reference to 'x' is ambiguous}}
+ int i = AB::x; // expected-error {{reference to 'x' is ambiguous}}
+
+ struct AB::y bar;
+ float f = AB::y; // expected-error {{a type named 'y' is hidden by a declaration in a different namespace}}
+ AB::z(i);
+ AB::z(f);
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6-0x.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6-0x.cpp
new file mode 100644
index 0000000..c745c84
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6-0x.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// XFAIL: *
+// Our C++0x doesn't currently have specialized destructor name handling,
+// since the specification is still in flux.
+struct C {
+ typedef int I;
+};
+
+typedef int I1, I2;
+extern int* p;
+extern int* q;
+
+void f() {
+ p->C::I::~I();
+ q->I1::~I2();
+}
+
+struct A {
+ ~A();
+};
+
+typedef A AB;
+int main() {
+ AB *p;
+ p->AB::~AB();
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp
new file mode 100644
index 0000000..0956de3
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct C {
+ typedef int I;
+};
+
+typedef int I1, I2;
+extern int* p;
+extern int* q;
+
+void f() {
+ p->C::I::~I();
+ q->I1::~I2();
+}
+
+struct A {
+ ~A();
+};
+
+typedef A AB;
+int main() {
+ AB *p;
+ p->AB::~AB(); // expected-error{{expected the class name after '~' to name a destructor}}
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp
new file mode 100644
index 0000000..ab0dc24
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// When looking up a namespace-name in a using-directive or
+// namespace-alias-definition, only namespace names are considered.
+
+struct ns1 {};
+void ns2();
+int ns3 = 0;
+
+namespace ns0 {
+ namespace ns1 {
+ struct test0 {};
+ }
+ namespace ns2 {
+ struct test1 {};
+ }
+ namespace ns3 {
+ struct test2 {};
+ }
+}
+
+using namespace ns0;
+
+namespace test3 = ns1;
+namespace test4 = ns2;
+namespace test5 = ns3;
+
+using namespace ns1;
+using namespace ns2;
+using namespace ns3;
+
+test0 a;
+test1 b;
+test2 c;
+
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p11.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p11.cpp
new file mode 100644
index 0000000..a1cf529
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p11.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+static const int a = 10;
+
+void f0(int a,
+ int b = a) { // expected-error {{default argument references parameter 'a'}}
+}
+
+template<int a,
+ int b = a>
+class A {
+};
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p12.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p12.cpp
new file mode 100644
index 0000000..878ff07
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p12.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct S {};
+S E0;
+
+namespace {
+ enum {
+ E0 = 1,
+ E1 = E0 + 1
+ };
+}
+
+
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p13.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p13.cpp
new file mode 100644
index 0000000..58d7ff4
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p13.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct S {
+ static const int f0 = 0;
+ static int f1;
+};
+
+int S::f1 = f0;
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp
new file mode 100644
index 0000000..0fa4f65
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++0x [basic.lookup.unqual]p14:
+// If a variable member of a namespace is defined outside of the
+// scope of its namespace then any name used in the definition of
+// the variable member (after the declarator-id) is looked up as if
+// the definition of the variable member occurred in its namespace.
+
+namespace N {
+ struct S {};
+ S i;
+ extern S j;
+ extern S j2;
+}
+
+int i = 2;
+N::S N::j = i;
+N::S N::j2(i);
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p15.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p15.cpp
new file mode 100644
index 0000000..253d15e
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p15.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// XFAIL: *
+
+class C {
+public:
+ C(int a, int b);
+};
+
+C::C(int a, // expected-note {{previous definition}}
+ int b) // expected-note {{previous definition}}
+try {
+ int c;
+
+} catch (int a) { // expected-error {{redefinition of 'a'}}
+ int b; // expected-error {{redefinition of 'b'}}
+ ++c; // expected-error {{use of undeclared identifier 'c'}}
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp
new file mode 100644
index 0000000..20a7ae0
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int f;
+
+namespace N0 {
+ struct A {
+ friend void f();
+ void g() {
+ int i = f(1);
+ }
+ };
+}
+
+namespace N1 {
+ struct A {
+ friend void f(A &);
+ operator int();
+ void g(A a) {
+ // ADL should not apply to the lookup of 'f', it refers to the typedef
+ // above.
+ int i = f(a);
+ }
+ };
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp
new file mode 100644
index 0000000..d2afd5d
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR5741
+namespace test0 {
+ struct A {
+ struct B { };
+ struct C;
+ };
+
+ struct A::C : B { };
+}
+
+// Test that successive base specifiers don't screw with each other.
+namespace test1 {
+ struct Opaque1 {};
+ struct Opaque2 {};
+
+ struct A {
+ struct B { B(Opaque1); };
+ };
+ struct B {
+ B(Opaque2);
+ };
+
+ struct C : A, B {
+ // Apparently the base-or-member lookup is actually ambiguous
+ // without this qualification.
+ C() : A(), test1::B(Opaque2()) {}
+ };
+}
+
+// Test that we don't find the injected class name when parsing base
+// specifiers.
+namespace test2 {
+ template <class T> struct bar {};
+ template <class T> struct foo : bar<foo> {}; // expected-error {{use of class template foo requires template arguments}} expected-note {{template is declared here}}
+}