]> granicus.if.org Git - clang/commitdiff
Enable expression transformations in the current-instantiation
authorDouglas Gregor <dgregor@apple.com>
Wed, 28 Jul 2010 15:14:14 +0000 (15:14 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 28 Jul 2010 15:14:14 +0000 (15:14 +0000)
rebuilder, i.e., remove a silly short-sighted hack from long
ago. Thanks to Abramo Bagnara for the test case/bug report!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109583 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplate.cpp
test/SemaTemplate/current-instantiation.cpp

index ea77a189f7502c36d7658431b91dd32742b19760..03e5281d836818ce1bdc25778d0e54a0ba9203ee 100644 (file)
@@ -5427,15 +5427,6 @@ namespace {
       this->Loc = Loc;
       this->Entity = Entity;
     }
-      
-    /// \brief Transforms an expression by returning the expression itself
-    /// (an identity function).
-    ///
-    /// FIXME: This is completely unsafe; we will need to actually clone the
-    /// expressions.
-    Sema::OwningExprResult TransformExpr(Expr *E) {
-      return getSema().Owned(E->Retain());
-    }
   };
 }
 
index c631dd71d1748d81063006d4d76ce8697f5f48a7..8caac9399a8747ba02c3aad265657ab561685327 100644 (file)
@@ -164,3 +164,38 @@ namespace ConstantInCurrentInstantiation {
   template<typename T>
   int X<T>::array[X<T>::value] = { 1, 2 };
 }
+
+namespace Expressions {
+  template <bool b>
+  struct Bool {
+    enum anonymous_enum { value = b };
+  };
+  struct True : public Bool<true> {};
+  struct False : public Bool<false> {};
+
+  template <typename T1, typename T2>
+  struct Is_Same : public False {};
+  template <typename T>
+  struct Is_Same<T, T> : public True {};
+
+  template <bool b, typename T = void>
+  struct Enable_If {};
+  template <typename T>
+  struct Enable_If<true, T>  {
+    typedef T type;
+  };
+
+  template <typename T>
+  class Class {
+  public:
+    template <typename U>
+    typename Enable_If<Is_Same<U, Class>::value, void>::type
+    foo();
+  };
+
+
+  template <typename T>
+  template <typename U>
+  typename Enable_If<Is_Same<U, Class<T> >::value, void>::type
+  Class<T>::foo() {}
+}