Fix assertion failure in self-host (and probably bogus template instantiation
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 19 Dec 2012 02:27:38 +0000 (02:27 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 19 Dec 2012 02:27:38 +0000 (02:27 +0000)
too). When instantiating a direct-initializer, if we find it has zero
arguments, produce an empty ParenListExpr rather than returning a null
expression.

llvm-svn: 170490

clang/lib/Sema/TreeTransform.h
clang/test/SemaTemplate/instantiate-member-initializers.cpp

index 52f6c4d..c161d8c 100644 (file)
@@ -2622,10 +2622,6 @@ ExprResult TreeTransform<Derived>::TransformInitializer(Expr *Init,
                                         Construct->getLocEnd(),
                                         Construct->getType());
 
-  // Treat an empty initializer like none.
-  if (NewArgs.empty())
-    return SemaRef.Owned((Expr*)0);
-
   // Build a ParenListExpr to represent anything else.
   SourceRange Parens = Construct->getParenRange();
   return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
index 45503b3..297ae91 100644 (file)
@@ -25,3 +25,13 @@ public:
   BB() : AA<T>(1) {}
 };
 BB<int> x;
+
+struct X {
+  X();
+};
+template<typename T>
+struct Y {
+  Y() : x() {}
+  X x;
+};
+Y<int> y;