reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    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
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct A0 {
  struct K { };
};

template <typename T> struct B0: A0 {
  static void f() {
    K k;
  }
};

namespace E1 {
  typedef double A; 

  template<class T> class B {
    typedef int A; 
  };

  template<class T> 
  struct X : B<T> {
    A* blarg(double *dp) {
      return dp;
    }
  };
}

namespace E2 {
  struct A { 
    struct B;
    int *a;
    int Y;
  };
    
  int a;
  template<class T> struct Y : T { 
    struct B { /* ... */ };
    B b; 
    void f(int i) { a = i; } 
    Y* p;
  }; 
  
  Y<A> ya;
}

namespace PR14402 {
  template<typename T>
  struct A {
    typedef int n;
    int f();

    struct B {};
    struct C : B {
      // OK, can't be sure whether we derive from A yet.
      using A::n;
      int g() { return f(); }
    };

    struct D {
      using A::n; // expected-error {{using declaration refers into 'A<T>::', which is not a base class of 'D'}}
      int g() { return f(); } // expected-error {{call to non-static member function 'f' of 'A' from nested type 'D'}}
    };

    struct E { char &f(); };
    struct F : E {
      // FIXME: Reject this prior to instantiation; f() is known to return int.
      char &g() { return f(); }
      // expected-error@-1 {{'PR14402::A<int>::f' is not a member of class 'PR14402::A<int>::F'}}
      // expected-error@-2 {{non-const lvalue reference to type 'char' cannot bind to a temporary of type 'int'}}
    };
  };

  template<> struct A<int>::B : A<int> {};
  A<int>::C::n n = A<int>::C().g();

  // 'not a member'
  char &r = A<int>::F().g(); // expected-note {{in instantiation of}}
  template<> struct A<char>::E : A<char> {};
  // 'cannot bind to a temporary'
  char &s = A<char>::F().g(); // expected-note {{in instantiation of}}

  struct X;
  struct X { void f(); };
  struct X;
  template<typename T> struct Y : X {
    void g() {
      X::f();
    }
  };
}