temp_arg_template.cpp 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. template<template<typename T> class X> struct A; // expected-note 2{{previous template template parameter is here}}
  3. template<template<typename T, int I> class X> struct B; // expected-note{{previous template template parameter is here}}
  4. template<template<int I> class X> struct C; // expected-note{{previous non-type template parameter with type 'int' is here}}
  5. template<class> struct X; // expected-note{{too few template parameters in template template argument}}
  6. template<int N> struct Y; // expected-note{{template parameter has a different kind in template argument}}
  7. template<long N> struct Ylong; // expected-note{{template non-type parameter has a different type 'long' in template argument}}
  8. namespace N {
  9. template<class> struct Z;
  10. }
  11. template<class, class> struct TooMany; // expected-note{{too many template parameters in template template argument}}
  12. A<X> *a1;
  13. A<N::Z> *a2;
  14. A< ::N::Z> *a3;
  15. A<Y> *a4; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
  16. A<TooMany> *a5; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
  17. B<X> *a6; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
  18. C<Y> *a7;
  19. C<Ylong> *a8; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
  20. template<typename T> void f(int);
  21. A<f> *a9; // expected-error{{must be a class template}}
  22. // Evil digraph '<:' is parsed as '[', expect error.
  23. A<::N::Z> *a10; // expected-error{{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}}
  24. // Do not do a digraph correction here.
  25. A<: :N::Z> *a11; // expected-error{{expected expression}} \
  26. expected-error{{C++ requires a type specifier for all declarations}}
  27. // PR7807
  28. namespace N {
  29. template <typename, typename = int>
  30. struct X
  31. { };
  32. template <typename ,int>
  33. struct Y
  34. { X<int> const_ref(); };
  35. template <template<typename,int> class TT, typename T, int N>
  36. int operator<<(int, TT<T, N> a) { // expected-note{{candidate template ignored}}
  37. 0 << a.const_ref(); // expected-error{{invalid operands to binary expression ('int' and 'X<int>')}}
  38. }
  39. void f0( Y<int,1> y){ 1 << y; } // expected-note{{in instantiation of function template specialization 'N::operator<<<Y, int, 1>' requested here}}
  40. }
  41. // PR12179
  42. template <typename Primitive, template <Primitive...> class F> // expected-warning {{variadic templates are a C++11 extension}}
  43. struct unbox_args {
  44. typedef typename Primitive::template call<F> x;
  45. };
  46. template <template <typename> class... Templates> // expected-warning {{variadic templates are a C++11 extension}}
  47. struct template_tuple {};
  48. template <typename T>
  49. struct identity {};
  50. template <template <typename> class... Templates> // expected-warning {{variadic templates are a C++11 extension}}
  51. template_tuple<Templates...> f7() {}
  52. void foo() {
  53. f7<identity>();
  54. }