1 | // RUN: %clang_cc1 -triple x86_64-linux-gnu -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s |
2 | // RUN: %clang_cc1 -triple i686-pc-win32 -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 -DMS %s |
3 | |
4 | template <bool> struct enable_if {}; |
5 | template<> struct enable_if<true> { typedef void type; }; |
6 | |
7 | template <typename, typename> struct is_same { static constexpr bool value = false; }; |
8 | template <typename T> struct is_same<T, T> { static constexpr bool value = true; }; |
9 | |
10 | |
11 | |
12 | |
13 | struct S { |
14 | // The only numeric types S can be converted to is __int128 and __float128. |
15 | template <typename T, typename = typename enable_if< |
16 | !((__is_integral(T) && sizeof(T) != 16) || |
17 | is_same<T, float>::value || |
18 | is_same<T, double>::value || |
19 | is_same<T, long double>::value)>::type> |
20 | operator T() { return T(); } |
21 | }; |
22 | |
23 | void f() { |
24 | #ifdef MS |
25 | // When targeting Win32, __float128 and __int128 do not exist, so the S |
26 | // object cannot be converted to anything usable in the expression. |
27 | // expected-error@+2{{invalid operands to binary expression ('S' and 'double')}} |
28 | #endif |
29 | double d = S() + 1.0; |
30 | #ifndef MS |
31 | // expected-error@-2{{use of overloaded operator '+' is ambiguous}} |
32 | // expected-note@-3 36{{built-in candidate operator+}} |
33 | #endif |
34 | } |
35 | |