brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · b5da1b1 Raw
171 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2class A;3 4class S {5public:6   template<typename T> struct A {7     struct Nested {8       typedef T type;9     };10   };11};12 13int i;14S::A<int>::Nested::type *ip = &i;15 16template<typename T>17struct Outer {18  template<typename U>19  class Inner0;20 21  template<typename U>22  class Inner1 {23    struct ReallyInner;24 25    T foo(U);26    template<typename V> T bar(V);27    template<typename V> T* bar(V);28 29    static T value1;30    static U value2;31  };32};33 34template<typename X>35template<typename Y>36class Outer<X>::Inner0 {37public:38  void f(X, Y);39};40 41template<typename X>42template<typename Y>43void Outer<X>::Inner0<Y>::f(X, Y) {44}45 46template<typename X>47template<typename Y>48struct Outer<X>::Inner1<Y>::ReallyInner {49  static Y value3;50 51  void g(X, Y);52};53 54template<typename X>55template<typename Y>56void Outer<X>::Inner1<Y>::ReallyInner::g(X, Y) {57}58 59template<typename X>60template<typename Y>61X Outer<X>::Inner1<Y>::foo(Y) {62  return X();63}64 65template<typename X>66template<typename Y>67template<typename Z>68X Outer<X>::Inner1<Y>::bar(Z) {69  return X();70}71 72template<typename X>73template<typename Y>74template<typename Z>75X* Outer<X>::Inner1<Y>::bar(Z) {76  return 0;77}78 79template<typename X>80template<typename Y>81X Outer<X>::Inner1<Y>::value1 = 0;82 83template<typename X>84template<typename Y>85Y Outer<X>::Inner1<Y>::value2 = Y();86 87template<typename X>88template<typename Y>89Y Outer<X>::Inner1<Y>::ReallyInner::value3 = Y();90 91template<typename X>92template<typename Y>93Y Outer<X>::Inner1<Y*>::ReallyInner::value4; // expected-error{{'Outer<X>::Inner1<Y *>::ReallyInner'}}94 95 96template<typename T>97struct X0 { };98 99template<typename T>100struct X0<T*> {101  template<typename U>102  void f(U u = T()) { }103};104 105// PR5103106template<typename>107struct X1 {108  template<typename, bool = false> struct B { };109};110template struct X1<int>::B<bool>;111 112// Template template parameters113template<typename T>114struct X2 {115  template<template<class U, T Value> class>  // expected-error {{cannot have type 'float'}}116                                              // expected-error@-1 {{cannot be narrowed from type 'long long' to 'int'}}117                                              // expected-note@-2 {{previous template template parameter is here}}118    struct Inner { };119};120 121template<typename T, int Value>122  struct X2_arg;123 124X2<int>::Inner<X2_arg> x2i1;125X2<float> x2a; // expected-note{{instantiation}}126X2<long long>::Inner<X2_arg> x2i3; // expected-note {{has different template parameters}}127 128namespace PR10896 {129  template<typename TN>130  class Foo {131 132  public:133    void foo() {}134  private:135 136    template<typename T>137    T SomeField; // expected-error {{non-static data member 'SomeField' cannot be declared as a template}}138    template<> int SomeField2; // expected-error {{extraneous 'template<>' in declaration of variable 'SomeField2'}}139  };140 141  void g() {142    Foo<int> f;143    f.foo();144  }145}146 147namespace PR10924 {148  template< class Topology, class ctype >149  struct ReferenceElement150  {151  };152 153  template< class Topology, class ctype >154  template< int codim >155  class ReferenceElement< Topology, ctype > :: BaryCenterArray // expected-error{{out-of-line definition of 'BaryCenterArray' does not match any declaration in 'PR10924::ReferenceElement<Topology, ctype>'}}156  {157  };158}159 160class Outer1 {161    template <typename T> struct X;162    template <typename T> int X<T>::func() {} //  expected-error{{out-of-line definition of 'func' from class 'Outer1::X<T>' without definition}}163};164 165namespace RefPack {166  template<const int &...N> struct A { template<typename ...T> void f(T (&...t)[N]); };167  constexpr int k = 10;168  int arr[10];169  void g() { A<k>().f(arr); }170}171