File: temp_func_order.cpp

package info (click to toggle)
llvm-toolchain-snapshot 1%3A21~%2B%2B20250612091244%2B3f0cf742ac4e-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,204,364 kB
  • sloc: cpp: 7,565,811; ansic: 1,415,365; asm: 1,031,257; python: 250,248; f90: 93,670; objc: 70,556; lisp: 41,926; pascal: 17,847; sh: 10,009; ml: 5,111; perl: 4,720; awk: 3,523; makefile: 3,423; javascript: 2,272; xml: 892; fortran: 763
file content (95 lines) | stat: -rw-r--r-- 1,803 bytes parent folder | download | duplicates (40)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// RUN: %clang_cc1 -fsyntax-only -verify %s
template<typename T>
int &f0(T);

template<typename T>
float &f0(T*);

void test_f0(int i, int *ip) {
  int &ir = f0(i);
  float &fr = f0(ip);
}

template<typename T, typename U>
int &f1(T, U);

template<typename T>
float &f1(T, T);

void test_f1(int i, float f) {
  int &ir = f1(i, f);
  float &fr1 = f1(i, i);
  float &fr2 = f1(f, f);
}

template<typename T, typename U>
struct A { };

template<typename T>
int &f2(T);

template<typename T, typename U>
float &f2(A<T, U>);

template<typename T>
double &f2(A<T, T>);

void test_f2(int i, A<int, float> aif, A<int, int> aii) {
  int &ir = f2(i);
  float &fr = f2(aif);
  double &dr = f2(aii);
}

template<typename T, typename U>
int &f3(T*, U); // expected-note{{candidate}}

template<typename T, typename U>
float &f3(T, U*); // expected-note{{candidate}}

void test_f3(int i, int *ip, float *fp) {
  int &ir = f3(ip, i);
  float &fr = f3(i, fp);
  f3(ip, ip); // expected-error{{ambiguous}}
}

template<typename T>
int &f4(T&);

template<typename T>
float &f4(const T&);

void test_f4(int i, const int ic) {
  int &ir1 = f4(i);
  float &fr1 = f4(ic);
}

template<typename T, typename U>
int &f5(T&, const U&); // expected-note{{candidate}}

template<typename T, typename U>
float &f5(const T&, U&); // expected-note{{candidate}}

void test_f5(int i, const int ic) {
  f5(i, i); // expected-error{{ambiguous}}
}

template<typename T, typename U>
int &f6(T&, U&);

template<typename T, typename U>
float &f6(const T&, U&);

void test_f6(int i, const int ic) {
  int &ir = f6(i, i);
  float &fr = f6(ic, ic);
}

struct CrazyFun {
  template<typename T, typename U> operator A<T, U>();
  template<typename T> operator A<T, T>();
};

void fun(CrazyFun cf) {
  A<int, float> aif = cf;
  A<int, int> aii = cf;  
}