1762bb9d0ad20320b9f97a841dce57ba5e8e48b07Richard Smith// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson// C++0x N2914.
3cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson
4cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlssonstruct B {
5cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson  void f(char);
6cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson  void g(char);
7cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson  enum E { e };
8cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson  union { int x; };
9cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson};
10cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson
11cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlssonclass C {
12cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson  int g();
13cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson};
14cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson
15cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlssonclass D2 : public B {
16cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson  using B::f;
17cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson  using B::e;
18cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson  using B::x;
19cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson  using C::g; // expected-error{{using declaration refers into 'C::', which is not a base class of 'D2'}}
20cf9f921268e67703d9cddcf9f2d6ac057c4c3cc8Anders Carlsson};
21604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall
22604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCallnamespace test1 {
23604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall  struct Base {
24604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall    int foo();
25604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall  };
26604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall
27604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall  struct Unrelated {
28604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall    int foo();
29604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall  };
30604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall
31604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall  struct Subclass : Base {
32604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall  };
33604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall
34604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall  namespace InnerNS {
35604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall    int foo();
36604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall  }
37604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall
38604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall  // We should be able to diagnose these without instantiation.
39604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall  template <class T> struct C : Base {
40604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall    using InnerNS::foo; // expected-error {{not a class}}
41604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall    using Base::bar; // expected-error {{no member named 'bar'}}
42604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall    using Unrelated::foo; // expected-error {{not a base class}}
43604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall    using C::foo; // expected-error {{refers to its own class}}
44604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall    using Subclass::foo; // expected-error {{not a base class}}
45604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall  };
46604e7f14d672af80ca5b9044f30f3dc23d37ddd5John McCall}
47