brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 9b106f1 Raw
81 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s4 5// Clang used to crash trying to recover while adding 'this->' before Work(x);6 7template <typename> struct A {8  static void Work(int);  // expected-note{{here}}9};10 11template <typename T> struct B : public A<T> {12  template <typename T2> B(T2 x) {13    Work(x);  // expected-error{{explicit qualification required}}14  }15};16 17void Test() {18  B<int> b(0);  // expected-note{{in instantiation of function template}}19}20 21 22// Don't crash here.23namespace PR16134 {24  template <class P> struct S // expected-error {{expected ';'}}25  template <> static S<Q>::f() // expected-error +{{}}26}27 28namespace PR16225 {29  template <typename T> void f();30  template <typename C> void g(C*) {31    struct LocalStruct : UnknownBase<Mumble, C> { };  // expected-error {{use of undeclared identifier 'Mumble'}}32    f<LocalStruct>();33#if __cplusplus <= 199711L34    // expected-warning@-2 {{template argument uses local type 'LocalStruct'}}35    // expected-note@-3 {{while substituting explicitly-specified template arguments}}36#endif37    struct LocalStruct2 : UnknownBase<C> { };  // expected-error {{no template named 'UnknownBase'}}38  }39  struct S;40  void h() {41    g<S>(0);42#if __cplusplus <= 199711L43    // expected-note@-2 {{in instantiation of function template specialization}}44#endif45  }46}47 48namespace test1 {49  template <typename> class ArraySlice {};50  class Foo;51  class NonTemplateClass { // #defined-here52    void MemberFunction(ArraySlice<Foo>, int);53    template <class T> void MemberFuncTemplate(ArraySlice<T>, int);54  };55  void NonTemplateClass::MemberFunction(ArraySlice<Foo> resource_data,56                                        int now) {57    // expected-note@+1 {{in instantiation of function template specialization 'test1::NonTemplateClass::MemberFuncTemplate<test1::Foo>'}}58    MemberFuncTemplate(resource_data, now);59  }60  template <class T>61  void NonTemplateClass::MemberFuncTemplate(ArraySlice<T> resource_data, int) {62    // expected-error@+1 {{member 'UndeclaredMethod' used before its declaration}}63    UndeclaredMethod(resource_data);64  }65  // expected-error@+3 {{out-of-line definition of 'UndeclaredMethod' does not match any declaration}}66  // expected-note@+2 {{member is declared here}}67  // expected-note@#defined-here {{defined here}}68  void NonTemplateClass::UndeclaredMethod() {}69}70 71namespace GH135621 {72  template <class T> struct S {};73  // expected-note@-1 {{class template declared here}}74  template <class T2> void f() {75    S<T2>::template S<int>;76    // expected-error@-1 {{'S' is expected to be a non-type template, but instantiated to a class template}}77  }78  template void f<int>();79  // expected-note@-1 {{requested here}}80} // namespace GH13562181