From cd6d5f43908cb4c2cbd644c35b6f21e9ade9a697 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 19 Dec 2012 02:27:38 +0000 Subject: [PATCH] Fix assertion failure in self-host (and probably bogus template instantiation too). When instantiating a direct-initializer, if we find it has zero arguments, produce an empty ParenListExpr rather than returning a null expression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170490 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/TreeTransform.h | 4 ---- test/SemaTemplate/instantiate-member-initializers.cpp | 10 ++++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 52f6c4d4c0..c161d8cfcb 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -2622,10 +2622,6 @@ ExprResult TreeTransform::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, diff --git a/test/SemaTemplate/instantiate-member-initializers.cpp b/test/SemaTemplate/instantiate-member-initializers.cpp index 45503b38b3..297ae917bb 100644 --- a/test/SemaTemplate/instantiate-member-initializers.cpp +++ b/test/SemaTemplate/instantiate-member-initializers.cpp @@ -25,3 +25,13 @@ public: BB() : AA(1) {} }; BB x; + +struct X { + X(); +}; +template +struct Y { + Y() : x() {} + X x; +}; +Y y; -- 2.40.0