injected-class-name.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. template<typename T>
  3. struct X {
  4. X<T*> *ptr;
  5. };
  6. X<int> x;
  7. template<>
  8. struct X<int***> {
  9. typedef X<int***> *ptr;
  10. };
  11. X<float>::X<int> xi = x; // expected-error{{qualified reference to 'X' is a constructor name rather than a template name wherever a constructor can be declared}}
  12. // [temp.local]p1:
  13. // FIXME: test template template parameters
  14. template<typename T, typename U>
  15. struct X0 {
  16. typedef T type;
  17. typedef U U_type;
  18. typedef U_type U_type2;
  19. void f0(const X0&); // expected-note{{here}}
  20. void f0(X0&);
  21. void f0(const X0<T, U>&); // expected-error{{redecl}}
  22. void f1(const X0&); // expected-note{{here}}
  23. void f1(X0&);
  24. void f1(const X0<type, U_type2>&); // expected-error{{redecl}}
  25. void f2(const X0&); // expected-note{{here}}
  26. void f2(X0&);
  27. void f2(const ::X0<type, U_type2>&); // expected-error{{redecl}}
  28. };
  29. template<typename T, T N>
  30. struct X1 {
  31. void f0(const X1&); // expected-note{{here}}
  32. void f0(X1&);
  33. void f0(const X1<T, N>&); // expected-error{{redecl}}
  34. };
  35. namespace pr6326 {
  36. template <class T> class A {
  37. friend class A;
  38. };
  39. template class A<int>;
  40. }
  41. namespace ForwardDecls {
  42. template<typename T>
  43. struct X;
  44. template<typename T>
  45. struct X {
  46. typedef T foo;
  47. typedef X<T> xt;
  48. typename xt::foo *t;
  49. };
  50. }
  51. namespace ConflictingRedecl {
  52. template<typename> struct Nested {
  53. template<typename> struct Nested; // expected-error {{member 'Nested' has the same name as its class}}
  54. };
  55. }