Semantic analysis, ASTs, and unqualified name lookup support for C++
using directives, from Piotr Rak!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63646 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/member-name-lookup.cpp b/test/SemaCXX/member-name-lookup.cpp
index 4752f57..a191612 100644
--- a/test/SemaCXX/member-name-lookup.cpp
+++ b/test/SemaCXX/member-name-lookup.cpp
@@ -130,3 +130,17 @@
   a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'struct A'}}
   static_f(0); // okay
 }
+
+
+struct HasMemberType1 {
+  struct type { };
+};
+
+struct HasMemberType2 {
+  struct type { };
+};
+
+struct HasAnotherMemberType : HasMemberType1, HasMemberType2 { 
+  // FIXME: this is well-formed, but we diagnose an ambiguity here
+  //  struct type { };
+};
diff --git a/test/SemaCXX/using-directive.cpp b/test/SemaCXX/using-directive.cpp
new file mode 100644
index 0000000..f002098
--- /dev/null
+++ b/test/SemaCXX/using-directive.cpp
@@ -0,0 +1,74 @@
+// RUN: clang -fsyntax-only -verify %s
+
+namespace A {
+  short i; // expected-note{{candidate found by name lookup is 'A::i'}}
+  namespace B {
+    long i; // expected-note{{candidate found by name lookup is 'A::B::i'}}
+    void f() {} // expected-note{{candidate function}}
+    int k;
+    namespace E {} // \
+      expected-note{{candidate found by name lookup is 'A::B::E'}}
+  }
+
+  namespace E {} // expected-note{{candidate found by name lookup is 'A::E'}}
+
+  namespace C {
+    using namespace B;
+    namespace E {} // \
+      expected-note{{candidate found by name lookup is 'A::C::E'}}
+  }
+
+  void f() {} // expected-note{{candidate function}}
+
+  class K1 {
+    void foo();
+  };
+
+  void local_i() {
+    char i;
+    using namespace A;
+    using namespace B;
+    int a[sizeof(i) == sizeof(char)? 1 : -1]; // okay
+  }
+  namespace B {
+    int j;
+  }
+
+  void ambig_i() {
+    using namespace A;
+    using namespace A::B;
+    (void) i; // expected-error{{reference to 'i' is ambiguous}}
+    f(); // expected-error{{call to 'f' is ambiguous}}
+    (void) j; // okay
+    using namespace C;
+    (void) k; // okay
+    using namespace E; // expected-error{{reference to 'E' is ambiguous}}
+  }
+
+  struct K2 {}; // expected-note{{candidate found by name lookup is 'A::K2'}}
+}
+
+struct K2 {}; // expected-note{{candidate found by name lookup is 'K2'}}
+
+using namespace A;
+
+void K1::foo() {} // okay
+
+// FIXME: Do we want err_ovl_no_viable_function_in_init here?
+struct K2 k2; // expected-error{{reference to 'K2' is ambiguous}} \
+                 expected-error{{no matching constructor}}
+
+// FIXME: This case is incorrectly diagnosed!
+//K2 k3;
+
+
+class X {
+  // FIXME: produce a suitable error message for this
+  using namespace A; // expected-error{{expected unqualified-id}}
+};
+
+namespace N {
+  // FIXME: both of these should work, but they currently cause an ambiguity.
+  // struct K2;
+  // struct K2 { };
+}