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