brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 2890368 Raw
57 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3namespace test0 {4  char* p = 0; 5  template<class T> T g(T x = &p) { return x; }6  template int g<int>(int);	// OK even though &p isn't an int.7}8 9// Don't impose access restrictions on explicit instantiations.10namespace test1 {11  class A {12    class Private {};13  public:14    typedef Private Public;15  };16 17  template <class T> class Temp {18    static Temp<A::Public> make() { return Temp<A::Public>(); }19  };20  template class Temp<A::Private>;21 22  // FIXME: this ought to be an error, but it isn't because Sema is23  // silently failing to create a declaration for the explicit24  // instantiation.25  template class Temp<A::Private> Temp<int>::make();26}27 28// Don't impose access restrictions on explicit specializations,29// either.  This goes here because it's an extension of the rule for30// explicit instantiations and doesn't have any independent support.31namespace test2 {32  class A {33    class Private {}; // expected-note {{implicitly declared private here}}34  public:35    typedef Private Public;36  };37 38  template <class T> class Temp {39    static Temp<A::Public> make();40  };41  template <> class Temp<A::Private> {42  public:43    Temp(int x) {}44  };45 46  template <> class Temp<A::Private> Temp<int>::make() {47    return Temp<A::Public>(0);48  }49 50  template <>51  class Temp<char> {52    static Temp<A::Private> make() { // expected-error {{is a private member}}53      return Temp<A::Public>(0);54    }55  };56}57