diag-template-diffing-color.cpp 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // RUN: not %clang_cc1 -fsyntax-only -fcolor-diagnostics %s 2>&1 | FileCheck %s
  2. // RUN: not %clang_cc1 -fsyntax-only -fcolor-diagnostics -fdiagnostics-show-template-tree %s 2>&1 | FileCheck %s -check-prefix=TREE
  3. // REQUIRES: ansi-escape-sequences
  4. template<typename> struct foo {};
  5. void func(foo<int>);
  6. int main() {
  7. func(foo<double>());
  8. }
  9. // CHECK: {{.*}}candidate function not viable: no known conversion from 'foo<[[CYAN:.\[0;1;36m]]double[[RESET:.\[0m]]>' to 'foo<[[CYAN]]int[[RESET]]>' for 1st argument[[RESET]]
  10. // TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  11. // TREE: foo<
  12. // TREE: {{\[}}[[CYAN:.\[0;1;36m]]double[[RESET:.\[0m]] != [[CYAN]]int[[RESET]]]>[[RESET]]
  13. foo<int> A;
  14. foo<double> &B = A;
  15. // CHECK: {{.*}}non-const lvalue reference to type 'foo<[[CYAN]]double[[RESET]][[BOLD:.\[1m]]>' cannot bind to a value of unrelated type 'foo<[[CYAN]]int[[RESET]][[BOLD]]>'[[RESET]]
  16. // TREE: non-const lvalue reference cannot bind to a value of unrelated type
  17. // TREE: foo<
  18. // TREE: {{\[}}[[CYAN]]double[[RESET]][[BOLD:.\[1m]] != [[CYAN]]int[[RESET]][[BOLD]]]>[[RESET]]
  19. template<typename> class vector {};
  20. void set15(vector<const vector<int> >) {}
  21. void test15() {
  22. set15(vector<const vector<const int> >());
  23. }
  24. // CHECK: {{.*}}candidate function not viable: no known conversion from 'vector<const vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}int>>' to 'vector<const vector<int>>' for 1st argument
  25. // TREE: {{.*}}candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  26. // TREE: vector<
  27. // TREE: const vector<
  28. // TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= [[CYAN]](no qualifiers)[[RESET]]] int>>
  29. void set16(vector<vector<int> >) {}
  30. void test16() {
  31. set16(vector<const vector<int> >());
  32. }
  33. // CHECK: {{.*}}candidate function not viable: no known conversion from 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' to 'vector<vector<[...]>>' for 1st argument
  34. // TREE: {{.*}}candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  35. // TREE: vector<
  36. // TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= [[CYAN]](no qualifiers){{ ?}}[[RESET]]]{{ ?}}vector<
  37. // TREE: [...]>>
  38. void set17(vector<const vector<int> >) {}
  39. void test17() {
  40. set17(vector<vector<int> >());
  41. }
  42. // CHECK: candidate function not viable: no known conversion from 'vector<vector<[...]>>' to 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' for 1st argument
  43. // TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  44. // TREE: vector<
  45. // TREE: {{\[}}[[CYAN]](no qualifiers){{ ?}}[[RESET]]{{ ?}}!= [[CYAN]]const[[RESET]]] vector<
  46. // TREE: [...]>>
  47. void set18(vector<volatile vector<int> >) {}
  48. void test18() {
  49. set18(vector<const vector<int> >());
  50. }
  51. // CHECK: candidate function not viable: no known conversion from 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' to 'vector<[[CYAN]]volatile{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' for 1st argument
  52. // TREE: no matching function for call to 'set18'
  53. // TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  54. // TREE: vector<
  55. // TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= [[CYAN]]volatile[[RESET]]] vector<
  56. // TREE: [...]>>
  57. void set19(vector<const volatile vector<int> >) {}
  58. void test19() {
  59. set19(vector<const vector<int> >());
  60. }
  61. // CHECK: candidate function not viable: no known conversion from 'vector<const vector<[...]>>' to 'vector<const [[CYAN]]volatile{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' for 1st argument
  62. // TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  63. // TREE: vector<
  64. // TREE: [const != const [[CYAN]]volatile[[RESET]]] vector<
  65. // TREE: [...]>>
  66. namespace default_args {
  67. template <int x, int y = 1+1, int z = 2>
  68. class A {};
  69. void foo(A<0> &M) {
  70. // CHECK: no viable conversion from 'A<[...], (default) [[CYAN]]1 + 1[[RESET]][[BOLD]] aka [[CYAN]]2[[RESET]][[BOLD]], (default) [[CYAN]]2[[RESET]][[BOLD]]>' to 'A<[...], [[CYAN]]0[[RESET]][[BOLD]], [[CYAN]]0[[RESET]][[BOLD]]>'
  71. A<0, 0, 0> N = M;
  72. // CHECK: no viable conversion from 'A<[2 * ...], (default) [[CYAN]]2[[RESET]][[BOLD]]>' to 'A<[2 * ...], [[CYAN]]0[[RESET]][[BOLD]]>'
  73. A<0, 2, 0> N2 = M;
  74. }
  75. }