xref: /llvm-project/clang/test/Misc/diag-overload-cand-ranges.cpp (revision 176981ac58d3e4beb02b9d110524e72be509375d)
1 // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace
2 // CHECK:      error: no matching function
3 template <typename T> struct mcdata {
4   typedef int result_type;
5 };
6 template <class T> typename mcdata<T>::result_type wrap_mean(mcdata<T> const &);
7 // CHECK:      :{[[@LINE+1]]:19-[[@LINE+1]]:53}: note: {{.*}}: no overload of 'wrap_mean'
8 void add_property(double (*)(mcdata<double> const &));
f()9 void f() { add_property(&wrap_mean); }
10 
11 // CHECK:      error: no matching function
12 // CHECK:      :{[[@LINE+1]]:10-[[@LINE+1]]:51}: note: {{.*}}: cannot pass pointer to generic address space
baz(int * Data)13 void baz(__attribute__((opencl_private)) int *Data) {}
fizz()14 void fizz() {
15   int *Nop;
16   baz(Nop);
17   // CHECK:    error: no matching function
18   // CHECK:    :[[@LINE+1]]:53: note: {{.*}}: 'this' object is in address space '__private'
19   __attribute__((opencl_private)) static auto err = [&]() {};
20   err();
21 }
22 
23 // CHECK:      error: no matching function
24 struct Bar {
25 // CHECK:      :{[[@LINE+1]]:26-[[@LINE+1]]:32}: note: {{.*}} would lose const qualifier
fooBar26 static void foo(int num, int *X) {}
27 // CHECK:      :{[[@LINE+1]]:17-[[@LINE+1]]:25}: note: {{.*}} no known conversion
fooBar28 static void foo(int *err, int *x) {}
29 };
bar(const int * Y)30 void bar(const int *Y) {
31   Bar::foo(5, Y);
32 }
33 
34 struct InComp;
35 
36 struct A {};
37 struct B : public A{};
38 // CHECK:      error: no matching function
39 // CHECK:      :{[[@LINE+5]]:36-[[@LINE+5]]:50}: note: {{.*}}: cannot convert initializer
40 // CHECK:      error: no matching function
41 // CHECK:      :{[[@LINE+3]]:36-[[@LINE+3]]:50}: note: {{.*}}: cannot convert argument
42 // CHECK:      error: no matching function
43 // CHECK:      :{[[@LINE+1]]:11-[[@LINE+1]]:18}: note: {{.*}}: no known conversion
44 void hoge(char aa, const char *bb, const A& third);
45 
46 // CHECK:      error: no matching function
47 // CHECK:      :{[[@LINE+1]]:14-[[@LINE+1]]:16}: note: {{.*}}: cannot convert from base class
48 void derived(B*);
49 
func(const A & arg)50 void func(const A &arg) {
51   hoge(1, "pass", {{{arg}}});
52   InComp *a;
53   hoge(1, "pass", a);
54   hoge("first", 5, 6);
55   A *b;
56   derived(b);
57 }
58 
59 struct Q {
60   // CHECK:    error: invalid operands
61   // CHECK:    :[[@LINE+1]]:6: note: {{.*}}: 'this' argument has type 'const Q'
62   Q &operator+(void*);
63 };
64 
fuga(const Q q)65 void fuga(const Q q) { q + 3; }
66 
67 template <short T> class Type1 {};
68 // CHECK:      error: no matching function
69 // CHECK:      :{[[@LINE+1]]:43-[[@LINE+1]]:54}: note: {{.*}}: expects an lvalue
Function1(int zz,Type1<T> & x,int ww)70 template <short T> void Function1(int zz, Type1<T> &x, int ww) {}
71 
Function()72 void Function() { Function1(33, Type1<-42>(), 66); }
73