brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 77d2498 Raw
37 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-linux-gnu -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s2// RUN: %clang_cc1 -triple i686-pc-win32 -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 -DMS %s3 4template <bool> struct enable_if {};5template<> struct enable_if<true> { typedef void type; };6 7template <typename, typename> struct is_same { static constexpr bool value = false; };8template <typename T> struct is_same<T, T> { static constexpr bool value = true; };9 10 11 12 13struct S {14  // The only numeric types S can be converted to are [unsigned] __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 23void f() {24#ifdef MS25  // When targeting Win32, __float128 and __int128 do not exist, so the S26  // object cannot be converted to anything usable in the expression.27  // expected-error@+2{{invalid operands to binary expression ('S' and 'double')}}28#endif29  double d = S() + 1.0;30#ifndef MS31  // expected-error@-2{{use of overloaded operator '+' is ambiguous}}32  // expected-note@-3 {{built-in candidate operator+(__float128, double)}}33  // expected-note@-4 {{built-in candidate operator+(__int128, double)}}34  // expected-note@-5 {{built-in candidate operator+(unsigned __int128, double)}}35#endif36}37