69 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s3 4namespace ambig {5 struct Foo {6 operator int();7 operator const char *();8 };9 10 11 void func(const char*, long);12 void func(const char*, const char*);13 void func(int, int);14 15 bool doit(Foo x) {16 func(x, x); // expected-error {{call to 'func' is ambiguous}}17 // expected-note@* 3{{candidate}}18 // Check that two functions with best conversions are at the top.19 // CHECK: error: call to 'func' is ambiguous20 // CHECK-NEXT: func(x, x)21 // CHECK-NEXT: ^~~~22 // CHECK-NEXT: note: candidate function23 // CHECK-NEXT: void func(const char*, const char*)24 // CHECK-NEXT: ^25 // CHECK-NEXT: note: candidate function26 // CHECK-NEXT: void func(int, int)27 }28}29 30namespace bad_conversion {31 struct Foo {32 operator int();33 operator const char *();34 };35 36 37 void func(double*, const char*, long);38 void func(double*, const char*, const char*);39 void func(double*, int, int);40 41 bool doit(Foo x) {42 func((int*)0, x, x); // expected-error {{no matching function for call to 'func'}}43 // expected-note@* 3{{candidate}}44 // Check that two functions with best conversions are at the top.45 // CHECK: error: no matching function for call to 'func'46 // CHECK-NEXT: func((int*)0, x, x)47 // CHECK-NEXT: ^~~~48 // CHECK-NEXT: note: candidate function49 // CHECK-NEXT: void func(double*, const char*, const char*)50 // CHECK-NEXT: ^51 // CHECK-NEXT: note: candidate function52 // CHECK-NEXT: void func(double*, int, int)53 }54}55 56namespace bad_deduction {57 template <class> struct templ {};58 template <class T> void func(templ<T>);59 template <class T> void func(T*);60 template <class T> auto func(T&) -> decltype(T().begin());61 template <class T> auto func(const T&) -> decltype(T().begin());62 63 bool doit() {64 struct record {} r;65 func(r); // expected-error {{no matching function for call to 'func'}}66 // expected-note@* 4{{candidate}}67 }68}69