Clang Project

clang_source_code/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
4
5template <int> int f(int);  // expected-note {{candidate function}}
6#if __cplusplus <= 199711L
7// expected-note@-2 {{candidate function}}
8#endif
9
10template <signed char> int f(int); // expected-note {{candidate function}}
11#if __cplusplus <= 199711L
12// expected-note@-2 {{candidate function}}
13#endif
14
15int i1 = f<1>(0); // expected-error{{call to 'f' is ambiguous}}
16int i2 = f<1000>(0);
17#if __cplusplus <= 199711L
18// expected-error@-2{{call to 'f' is ambiguous}}
19#endif
20
21namespace PR6707 {
22  template<typename T, T Value>
23  struct X { };
24
25  template<typename T, T Value>
26  void f(X<T, Value>);
27
28  void g(X<int, 10> x) {
29    f(x);
30  }
31
32  static const unsigned char ten = 10;
33  template<typename T, T Value, typename U>
34  void f2(X<T, Value>, X<U, Value>);
35  // expected-note@-1 {{candidate template ignored: deduced values of conflicting types for parameter 'Value' (10 of type 'int' vs. 10 of type 'char')}}
36  // expected-note@-2 {{candidate template ignored: deduced values of conflicting types for parameter 'Value' (10 of type 'char' vs. 10 of type 'int')}}
37
38  void g2() {
39    f2(X<int, 10>(), X<char, ten>()); // expected-error {{no matching}}
40    f2(X<char, 10>(), X<int, ten>()); // expected-error {{no matching}}
41  }
42}
43