brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.5 KiB · 6f09258 Raw
207 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -pedantic-errors -verify %s2 3template<typename T> struct A {4  template<typename U> struct B {5    // FIXME: The standard does not seem to consider non-friend elaborated-type-specifiers that6    // declare partial specializations/explicit specializations/explicit instantiations to be7    // declarative, see https://lists.isocpp.org/core/2024/01/15325.php8    struct C;9    template<typename V> struct D;10 11    void f();12    template<typename V> void g();13 14    static int x;15    template<typename V> static int y;16 17    enum class E;18  };19};20 21template<typename T>22template<typename U>23struct A<T>::template B<U>::C { }; // expected-error{{'template' cannot be used after a declarative}}24 25template<>26template<>27struct A<int>::template B<bool>::C; // expected-error{{'template' cannot be used after a declarative}}28 29template<>30template<>31struct A<int>::template B<bool>::C { }; // expected-error{{'template' cannot be used after a declarative}}32 33template<typename T>34template<typename U>35template<typename V>36struct A<T>::template B<U>::D<V*>; // expected-error{{'template' cannot be used after a declarative}}37 38template<typename T>39template<typename U>40template<typename V>41struct A<T>::B<U>::template D<V**>; // expected-error{{'template' cannot be used after a declarative}}42 43template<typename T>44template<typename U>45template<typename V>46struct A<T>::template B<U>::D { }; // expected-error{{'template' cannot be used after a declarative}}47 48template<typename T>49template<typename U>50template<typename V>51struct A<T>::template B<U>::D<V*> { }; // expected-error{{'template' cannot be used after a declarative}}52 53template<typename T>54template<typename U>55template<typename V>56struct A<T>::B<U>::template D<V**> { }; // expected-error{{'template' cannot be used after a declarative}}57 58template<>59template<>60template<typename V>61struct A<int>::template B<bool>::D; // expected-error{{'template' cannot be used after a declarative}}62 63template<>64template<>65template<>66struct A<int>::template B<bool>::D<short>; // expected-error{{'template' cannot be used after a declarative}}67 68template<>69template<>70template<>71struct A<int>::B<bool>::template D<long>; // expected-error{{'template' cannot be used after a declarative}}72 73template<>74template<>75template<typename V>76struct A<int>::template B<bool>::D<V*>; // expected-error{{'template' cannot be used after a declarative}}77 78template<>79template<>80template<typename V>81struct A<int>::B<bool>::template D<V**>; // expected-error{{'template' cannot be used after a declarative}}82 83template<>84template<>85template<typename V>86struct A<int>::template B<bool>::D { }; // expected-error{{'template' cannot be used after a declarative}}87 88template<>89template<>90template<>91struct A<int>::template B<bool>::D<short> { }; // expected-error{{'template' cannot be used after a declarative}}92 93template<>94template<>95template<>96struct A<int>::B<bool>::template D<long> { }; // expected-error{{'template' cannot be used after a declarative}}97 98template<>99template<>100template<typename V>101struct A<int>::template B<bool>::D<V*> { }; // expected-error{{'template' cannot be used after a declarative}}102 103template<>104template<>105template<typename V>106struct A<int>::B<bool>::template D<V**> { }; // expected-error{{'template' cannot be used after a declarative}}107 108template<typename T>109template<typename U>110void A<T>::template B<U>::f() { } // expected-error{{'template' cannot be used after a declarative}}111 112template<>113template<>114void A<int>::template B<bool>::f() { } // expected-error{{'template' cannot be used after a declarative}}115 116template<typename T>117template<typename U>118template<typename V>119void A<T>::template B<U>::g() { } // expected-error{{'template' cannot be used after a declarative}}120 121template<>122template<>123template<>124void A<int>::B<bool>::template g<short>() { } // expected-error{{'template' cannot be used after a declarative}}125 126template<>127template<>128template<>129void A<int>::template B<bool>::g<long>() { } // expected-error{{'template' cannot be used after a declarative}}130 131template<>132template<>133template<typename V>134void A<int>::template B<bool>::g() { } // expected-error{{'template' cannot be used after a declarative}}135 136template<typename T>137template<typename U>138int A<T>::template B<U>::x = 0; // expected-error{{'template' cannot be used after a declarative}}139 140template<typename T>141template<typename U>142template<typename V>143int A<T>::template B<U>::y = 0; // expected-error{{'template' cannot be used after a declarative}}144 145template<typename T>146template<typename U>147template<typename V>148int A<T>::template B<U>::y<V*> = 0; // expected-error{{'template' cannot be used after a declarative}}149 150template<typename T>151template<typename U>152template<typename V>153int A<T>::B<U>::template y<V**> = 0; // expected-error{{'template' cannot be used after a declarative}}154 155template<>156template<>157template<typename V>158int A<int>::template B<bool>::y = 0; // expected-error{{'template' cannot be used after a declarative}}159 160template<>161template<>162template<>163int A<int>::template B<bool>::y<short> = 0; // expected-error{{'template' cannot be used after a declarative}}164 165template<>166template<>167template<>168int A<int>::B<bool>::template y<long> = 0; // expected-error{{'template' cannot be used after a declarative}}169 170template<>171template<>172template<typename V>173int A<int>::template B<bool>::y<V*> = 0; // expected-error{{'template' cannot be used after a declarative}}174 175template<>176template<>177template<typename V>178int A<int>::B<bool>::template y<V**> = 0; // expected-error{{'template' cannot be used after a declarative}}179template<typename T>180template<typename U>181enum class A<T>::template B<U>::E { a }; // expected-error{{'template' cannot be used after a declarative}}182 183template<>184template<>185enum class A<int>::template B<bool>::E; // expected-error{{'template' cannot be used after a declarative}}186 187template<>188template<>189enum class A<int>::template B<bool>::E { a }; // expected-error{{'template' cannot be used after a declarative}}190 191// FIXME: We don't call Sema::diagnoseQualifiedDeclaration for friend declarations right now192template<typename T>193struct F {194  // FIXME: f should be assumed to name a template per [temp.names] p3.4195  friend void T::f<int>();196  // expected-error@-1{{use 'template' keyword to treat 'f' as a dependent template name}}197  // expected-error@-2{{no candidate function template was found for}}198 199  // FIXME: We should diagnose the presence of 'template' here200  friend void T::template f<int>(); // expected-error{{no candidate function template was found for}}201  friend void T::template U<int>::f();202 203  // These should be allowed204  friend class T::template U<int>;205  friend class T::template U<int>::V;206};207