From a9e9ebcfb5268f2ebab8c46ea9e025e1c0caeddc Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sat, 19 May 2012 23:35:23 +0000 Subject: [PATCH] Make delegating initializers use a similar codepath to base initializers in dependent contexts. PR12890. llvm-svn: 157136 --- clang/lib/Sema/SemaDeclCXX.cpp | 10 ++++++++++ clang/test/SemaTemplate/delegating-constructors.cpp | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 9571a26..676063a 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2234,6 +2234,16 @@ Sema::BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, if (DelegationInit.isInvalid()) return true; + // If we are in a dependent context, template instantiation will + // perform this type-checking again. Just save the arguments that we + // received in a ParenListExpr. + // FIXME: This isn't quite ideal, since our ASTs don't capture all + // of the information that we have about the base + // initializer. However, deconstructing the ASTs is a dicey process, + // and this approach is far more likely to get the corner cases right. + if (CurContext->isDependentContext()) + DelegationInit = Owned(Init); + return new (Context) CXXCtorInitializer(Context, TInfo, InitRange.getBegin(), DelegationInit.takeAs(), InitRange.getEnd()); diff --git a/clang/test/SemaTemplate/delegating-constructors.cpp b/clang/test/SemaTemplate/delegating-constructors.cpp index e177b50..852b89d 100644 --- a/clang/test/SemaTemplate/delegating-constructors.cpp +++ b/clang/test/SemaTemplate/delegating-constructors.cpp @@ -29,3 +29,21 @@ namespace PR10457 { Foo f(1, 1); } } + +namespace PR12890 { + class Document + { + public: + Document() = default; + + template + explicit + Document(T&& t) : Document() + { + } + }; + void f() + { + Document d(1); + } +} -- 2.7.4