18237141bSHans Wennborg // RUN: %clang_cc1 -triple x86_64-linux-gnu -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s
28237141bSHans Wennborg // RUN: %clang_cc1 -triple i686-pc-win32 -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 -DMS %s
38237141bSHans Wennborg
48237141bSHans Wennborg template <bool> struct enable_if {};
58237141bSHans Wennborg template<> struct enable_if<true> { typedef void type; };
68237141bSHans Wennborg
78237141bSHans Wennborg template <typename, typename> struct is_same { static constexpr bool value = false; };
88237141bSHans Wennborg template <typename T> struct is_same<T, T> { static constexpr bool value = true; };
98237141bSHans Wennborg
108237141bSHans Wennborg
118237141bSHans Wennborg
128237141bSHans Wennborg
138237141bSHans Wennborg struct S {
14*70f59b5bSRichard Smith // The only numeric types S can be converted to are [unsigned] __int128 and __float128.
158237141bSHans Wennborg template <typename T, typename = typename enable_if<
168237141bSHans Wennborg !((__is_integral(T) && sizeof(T) != 16) ||
178237141bSHans Wennborg is_same<T, float>::value ||
188237141bSHans Wennborg is_same<T, double>::value ||
198237141bSHans Wennborg is_same<T, long double>::value)>::type>
operator TS208237141bSHans Wennborg operator T() { return T(); }
218237141bSHans Wennborg };
228237141bSHans Wennborg
f()238237141bSHans Wennborg void f() {
248237141bSHans Wennborg #ifdef MS
258237141bSHans Wennborg // When targeting Win32, __float128 and __int128 do not exist, so the S
268237141bSHans Wennborg // object cannot be converted to anything usable in the expression.
278237141bSHans Wennborg // expected-error@+2{{invalid operands to binary expression ('S' and 'double')}}
288237141bSHans Wennborg #endif
298237141bSHans Wennborg double d = S() + 1.0;
308237141bSHans Wennborg #ifndef MS
318237141bSHans Wennborg // expected-error@-2{{use of overloaded operator '+' is ambiguous}}
32*70f59b5bSRichard Smith // expected-note@-3 {{built-in candidate operator+(__float128, double)}}
33*70f59b5bSRichard Smith // expected-note@-4 {{built-in candidate operator+(__int128, double)}}
34*70f59b5bSRichard Smith // expected-note@-5 {{built-in candidate operator+(unsigned __int128, double)}}
358237141bSHans Wennborg #endif
368237141bSHans Wennborg }
37