From: Eli Friedman Date: Wed, 25 Jan 2012 01:05:57 +0000 (+0000) Subject: Make sure we correctly treat __is_convertible_to as an unevaluated context. PR11833. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3add9f0ac80b0a4d78611dcdb4fd89c37f1c13d8;p=clang Make sure we correctly treat __is_convertible_to as an unevaluated context. PR11833. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148893 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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, X0))]; } } +namespace is_convertible_to_instantiate { + // Make sure we don't try to instantiate the constructor. + template class A { A(int) { int a[x]; } }; + int x = __is_convertible_to(int, A<-1>); +} + void is_trivial() { { int arr[T(__is_trivial(int))]; }