diag-template-diffing-cxx98.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // RUN: not %clang_cc1 -fsyntax-only %s -std=c++98 2>&1 | FileCheck %s
  2. namespace PR14342 {
  3. template<typename T, char a> struct X {};
  4. X<int, 1> x = X<long, 257>();
  5. // CHECK: error: no viable conversion from 'X<long, [...]>' to 'X<int, [...]>'
  6. }
  7. namespace PR15513 {
  8. template <int x, int y = x+1>
  9. class A {};
  10. void foo(A<0> &M) {
  11. // CHECK: no viable conversion from 'A<[...], (default) x + 1 aka 1>' to 'A<[...], 0>'
  12. A<0, 0> N = M;
  13. // CHECK: no viable conversion from 'A<0, [...]>' to 'A<1, [...]>'
  14. A<1, 1> O = M;
  15. }
  16. }
  17. namespace default_args {
  18. template <int x, int y = 1+1, int z = 2>
  19. class A {};
  20. void foo(A<0> &M) {
  21. // CHECK: no viable conversion from 'A<[...], (default) 1 + 1 aka 2, (default) 2>' to 'A<[...], 0, 0>'
  22. A<0, 0, 0> N = M;
  23. // CHECK: no viable conversion from 'A<[2 * ...], (default) 2>' to 'A<[2 * ...], 0>'
  24. A<0, 2, 0> N2 = M;
  25. }
  26. }
  27. namespace qualifiers {
  28. template <class T>
  29. void foo(void (func(T*)), T*) {}
  30. template <class T>
  31. class vector{};
  32. void bar(const vector<int>*) {}
  33. void test(volatile vector<int>* V) {
  34. foo(bar, V);
  35. }
  36. // CHECK: candidate template ignored: deduced conflicting types for parameter 'T' ('const vector<[...]>' vs. 'volatile vector<[...]>')
  37. }