Clang Project

clang_source_code/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p4.cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
3
4template<class T> struct A { A(); };
5template<class T> int &f(T); 
6template<class T> float &f(T*); 
7template<class T> double &f(const T*);
8
9template<class T> void g(T); // expected-note{{candidate}}
10template<class T> void g(T&); // expected-note{{candidate}}
11
12template<class T> int &h(const T&); 
13template<class T> float &h(A<T>&);
14
15void m() { 
16  const int *p; 
17  double &dr1 = f(p); 
18  float x; 
19  g(x); // expected-error{{ambiguous}}
20  A<int> z; 
21  float &fr1 = h(z);
22  const A<int> z2; 
23  int &ir1 = h(z2);
24}
25
26
27namespace core_26909 {
28  template<typename T> struct A {};
29  template<typename T, typename U> void f(T&, U); // expected-note {{candidate}}
30  template<typename T, typename U> void f(T&&, A<U>); // expected-note {{candidate}} expected-warning 0-1{{extension}}
31  template<typename T, typename U> void g(const T&, U); // expected-note {{candidate}}
32  template<typename T, typename U> void g(T&, A<U>); // expected-note {{candidate}}
33
34  void h(int a, const char b, A<int> c) {
35    f(a, c); // expected-error{{ambiguous}}
36    g(b, c); // expected-error{{ambiguous}}
37  }
38}
39
40namespace PR22435 {
41  template<typename T, typename U> void foo(void (*)(T), const U &); // expected-note {{candidate}}
42  template<typename T, typename U> bool foo(void (*)(T &), U &); // expected-note {{candidate}}
43  void bar(const int x) { bool b = foo<char>(0, x); } // expected-error {{ambiguous}}
44}
45