diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 9bf1aa29d1744125a3271d856dc896527edd8189..2625fbb9c0046f2e793a8e094b1c387690165f25 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -5600,6 +5600,17 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, QualType LhsT, Expr *FromPtr = &From; InitializationKind Kind(InitializationKind::CreateCopy(KeyLoc, SourceLocation())); + #if ENABLE_BSC + if (Self.getLangOpts().BSC) { + ImplicitConversionSequence ICS = Self.TryImplicitConversion(FromPtr, RhsT, + /*SuppressUserConversions*/true, + Sema::AllowedExplicit::None, + /*InOverloadResolution*/ false, + /*CStyle=*/Kind.isCStyleOrFunctionalCast(), + /*allowObjCWritebackConversion=*/false); + return ICS.isStandard(); + } + #endif // Perform the initialization in an unevaluated context within a SFINAE // trap at translation unit scope. diff --git a/clang/test/BSC/Positive/Generic/TypeTrait/TypeTrait/TypeTrait.cbs b/clang/test/BSC/Positive/Generic/TypeTrait/TypeTrait/TypeTrait.cbs index 582b63962736fe7f62459d7379b3e547305fa8ed..76fffe624c16ffb20412c30378fcc93933c6814c 100644 --- a/clang/test/BSC/Positive/Generic/TypeTrait/TypeTrait/TypeTrait.cbs +++ b/clang/test/BSC/Positive/Generic/TypeTrait/TypeTrait/TypeTrait.cbs @@ -2,7 +2,6 @@ // RUN: %t.output // expected-no-diagnostics #include "TypeTrait.hbs" - typedef int MyInt; typedef int arr1[]; typedef int arr2[3]; @@ -48,9 +47,32 @@ int main() { printf("%d\n",is_same()); //1 printf("%d\n",is_same()); //0 printf("%d\n",is_convertible()); //1 - printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //0 printf("%d\n",is_convertible()); //1 printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //1 + printf("%d\n",is_convertible()); //1 + printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //1 + printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //1 + printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //1 + printf("%d\n",is_convertible()); //1 + printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //1 + printf("%d\n",is_convertible()); //1 + printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //0 + printf("%d\n",is_convertible()); //0 struct S s1; struct S s2; s1.foo(); //print "integral" diff --git a/clang/test/BSC/Positive/Generic/TypeTrait/TypeTrait/expected.txt b/clang/test/BSC/Positive/Generic/TypeTrait/TypeTrait/expected.txt index 5ee880ce266ef41396a4039ec18c1bca743baa37..d3385cf1242b1e2fef9f553bb8be1489a692cf5d 100644 --- a/clang/test/BSC/Positive/Generic/TypeTrait/TypeTrait/expected.txt +++ b/clang/test/BSC/Positive/Generic/TypeTrait/TypeTrait/expected.txt @@ -36,6 +36,29 @@ 0 1 0 +1 +1 +0 +0 +1 +0 +0 +0 +1 +0 +1 +1 +0 +0 +1 +1 +0 +0 +0 +0 +0 +0 +0 integral not integral integral