[cfe-commits] r148893 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/SemaCXX/type-traits.cpp

Eli Friedman eli.friedman at gmail.com
Tue Jan 24 17:05:57 PST 2012


Author: efriedma
Date: Tue Jan 24 19:05:57 2012
New Revision: 148893

URL: http://llvm.org/viewvc/llvm-project?rev=148893&view=rev
Log:
Make sure we correctly treat __is_convertible_to as an unevaluated context.  PR11833.


Modified:
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/test/SemaCXX/type-traits.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=148893&r1=148892&r2=148893&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Jan 24 19:05:57 2012
@@ -3166,8 +3166,9 @@
     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);

Modified: cfe/trunk/test/SemaCXX/type-traits.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/type-traits.cpp?rev=148893&r1=148892&r2=148893&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/type-traits.cpp (original)
+++ cfe/trunk/test/SemaCXX/type-traits.cpp Tue Jan 24 19:05:57 2012
@@ -1543,6 +1543,12 @@
   { 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))]; }





More information about the cfe-commits mailing list