blob: b3b270bfc936a31dc05ad7d25c9f1d1a7c17ccfe [file] [log] [blame]
Richard Smith6642bb32016-03-24 19:12:22 +00001// 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 Smith95853072016-03-25 00:08:53 +00006template<typename T, typename> struct Error { typedef typename T::error error; };
7struct X { template<typename T> friend typename Error<X, T>::error f(X, T); };
8struct Y { template<typename T> friend typename Error<Y, T>::error f(T, Y); };
Richard Smith6642bb32016-03-24 19:12:22 +00009
10void 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 Smith6642bb32016-03-24 19:12:22 +000018// CHECK: no type named 'error' in 'X'
Richard Smith95853072016-03-25 00:08:53 +000019// CHECK: no type named 'error' in 'Y'
Richard Smith6642bb32016-03-24 19:12:22 +000020// CHECK: no matching function for call to 'f'
Richard Smith95853072016-03-25 00:08:53 +000021
22
23struct 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};
48int *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 *>'