Richard Smith | 6642bb3 | 2016-03-24 19:12:22 +0000 | [diff] [blame] | 1 | // RUN: not %clang_cc1 %s -fsyntax-only 2>&1 | FileCheck %s |
| 2 | |
| 3 | // Ensure that the diagnostics we produce for this situation appear in a |
| 4 | // deterministic order. This requires ADL to provide lookup results in a |
| 5 | // deterministic order. |
Richard Smith | 9585307 | 2016-03-25 00:08:53 +0000 | [diff] [blame^] | 6 | template<typename T, typename> struct Error { typedef typename T::error error; }; |
| 7 | struct X { template<typename T> friend typename Error<X, T>::error f(X, T); }; |
| 8 | struct Y { template<typename T> friend typename Error<Y, T>::error f(T, Y); }; |
Richard Smith | 6642bb3 | 2016-03-24 19:12:22 +0000 | [diff] [blame] | 9 | |
| 10 | void g() { |
| 11 | f(X(), Y()); |
| 12 | } |
| 13 | |
| 14 | // We don't really care which order these two diagnostics appear (although the |
| 15 | // order below is source order, which seems best). The crucial fact is that |
| 16 | // there is one single order that is stable across multiple runs of clang. |
| 17 | // |
Richard Smith | 6642bb3 | 2016-03-24 19:12:22 +0000 | [diff] [blame] | 18 | // CHECK: no type named 'error' in 'X' |
Richard Smith | 9585307 | 2016-03-25 00:08:53 +0000 | [diff] [blame^] | 19 | // CHECK: no type named 'error' in 'Y' |
Richard Smith | 6642bb3 | 2016-03-24 19:12:22 +0000 | [diff] [blame] | 20 | // CHECK: no matching function for call to 'f' |
Richard Smith | 9585307 | 2016-03-25 00:08:53 +0000 | [diff] [blame^] | 21 | |
| 22 | |
| 23 | struct Oper { |
| 24 | template<typename T, typename U = typename Error<Oper, T>::error> operator T(); |
| 25 | |
| 26 | operator int*(); |
| 27 | operator float*(); |
| 28 | operator X*(); |
| 29 | operator Y*(); |
| 30 | |
| 31 | operator int(*[1])(); |
| 32 | operator int(*[2])(); |
| 33 | operator int(*[3])(); |
| 34 | operator int(*[4])(); |
| 35 | operator int(*[5])(); |
| 36 | operator int(*[6])(); |
| 37 | operator int(*[7])(); |
| 38 | operator int(*[8])(); |
| 39 | operator float(*[1])(); |
| 40 | operator float(*[2])(); |
| 41 | operator float(*[3])(); |
| 42 | operator float(*[4])(); |
| 43 | operator float(*[5])(); |
| 44 | operator float(*[6])(); |
| 45 | operator float(*[7])(); |
| 46 | operator float(*[8])(); |
| 47 | }; |
| 48 | int *p = Oper() + 0; |
| 49 | |
| 50 | // CHECK: no type named 'error' in 'Oper' |
| 51 | // CHECK: in instantiation of template class 'Error<Oper, int *>' |
| 52 | // CHECK: no type named 'error' in 'Oper' |
| 53 | // CHECK: in instantiation of template class 'Error<Oper, float *>' |
| 54 | // CHECK: no type named 'error' in 'Oper' |
| 55 | // CHECK: in instantiation of template class 'Error<Oper, X *>' |
| 56 | // CHECK: no type named 'error' in 'Oper' |
| 57 | // CHECK: in instantiation of template class 'Error<Oper, Y *>' |