diff options
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 5 | ||||
-rw-r--r-- | test/SemaCXX/type-traits.cpp | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 1b08aa2159..5c00e70af6 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -3166,8 +3166,9 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, BinaryTypeTrait BTT, InitializationKind Kind(InitializationKind::CreateCopy(KeyLoc, SourceLocation())); - // Perform the initialization within a SFINAE trap at translation unit - // scope. + // Perform the initialization in an unevaluated context within a SFINAE + // trap at translation unit scope. + EnterExpressionEvaluationContext Unevaluated(Self, Sema::Unevaluated); Sema::SFINAETrap SFINAE(Self, /*AccessCheckingSFINAE=*/true); Sema::ContextRAII TUContext(Self, Self.Context.getTranslationUnitDecl()); InitializationSequence Init(Self, To, Kind, &FromPtr, 1); diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp index 2b8714b5e0..c1783dab28 100644 --- a/test/SemaCXX/type-traits.cpp +++ b/test/SemaCXX/type-traits.cpp @@ -1543,6 +1543,12 @@ void is_convertible_to() { { int arr[T(__is_convertible_to(X0<int>, X0<float>))]; } } +namespace is_convertible_to_instantiate { + // Make sure we don't try to instantiate the constructor. + template<int x> class A { A(int) { int a[x]; } }; + int x = __is_convertible_to(int, A<-1>); +} + void is_trivial() { { int arr[T(__is_trivial(int))]; } |