temp_class_order.cpp 964 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. template<typename T, typename U>
  3. struct X1 {
  4. static const int value = 0;
  5. };
  6. template<typename T, typename U>
  7. struct X1<T*, U*> {
  8. static const int value = 1;
  9. };
  10. template<typename T>
  11. struct X1<T*, T*> {
  12. static const int value = 2;
  13. };
  14. template<typename T>
  15. struct X1<const T*, const T*> {
  16. static const int value = 3;
  17. };
  18. int array0[X1<int, int>::value == 0? 1 : -1];
  19. int array1[X1<int*, float*>::value == 1? 1 : -1];
  20. int array2[X1<int*, int*>::value == 2? 1 : -1];
  21. typedef const int* CIP;
  22. int array3[X1<const int*, CIP>::value == 3? 1 : -1];
  23. template<typename T, typename U>
  24. struct X2 { };
  25. template<typename T, typename U>
  26. struct X2<T*, U> { }; // expected-note{{matches}}
  27. template<typename T, typename U>
  28. struct X2<T, U*> { }; // expected-note{{matches}}
  29. template<typename T, typename U>
  30. struct X2<const T*, const U*> { };
  31. X2<int*, int*> x2a; // expected-error{{ambiguous}}
  32. X2<const int*, const int*> x2b;