func-template-decl.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
  2. namespace nodiag {
  3. template <typename T> requires bool(T())
  4. int A();
  5. template <typename U> requires bool(U())
  6. int A();
  7. } // end namespace nodiag
  8. namespace diag {
  9. namespace orig {
  10. template <typename T> requires true
  11. int A();
  12. template <typename T>
  13. int B();
  14. template <typename T> requires true
  15. int C();
  16. }
  17. template <typename T>
  18. int orig::A();
  19. // expected-error@-1{{out-of-line declaration of 'A' does not match any declaration in namespace 'diag::orig'}}
  20. template <typename T> requires true
  21. int orig::B();
  22. // expected-error@-1{{out-of-line declaration of 'B' does not match any declaration in namespace 'diag::orig'}}
  23. template <typename T> requires !0
  24. int orig::C();
  25. // expected-error@-1{{out-of-line declaration of 'C' does not match any declaration in namespace 'diag::orig'}}
  26. } // end namespace diag
  27. namespace nodiag {
  28. struct AA {
  29. template <typename T> requires someFunc(T())
  30. int A();
  31. };
  32. template <typename T> requires someFunc(T())
  33. int AA::A() { return sizeof(T); }
  34. } // end namespace nodiag
  35. namespace diag {
  36. template <unsigned N>
  37. struct TA {
  38. template <template <unsigned> class TT> requires TT<N>::happy
  39. int A();
  40. };
  41. template <unsigned N>
  42. template <template <unsigned> class TT> int TA<N>::A() { return sizeof(TT<N>); }
  43. // expected-error@-1{{out-of-line definition of 'A' does not match any declaration in 'TA<N>'}}
  44. } // end namespace diag