]> granicus.if.org Git - clang/commitdiff
Make delegating initializers use a similar codepath to base initializers in dependent...
authorEli Friedman <eli.friedman@gmail.com>
Sat, 19 May 2012 23:35:23 +0000 (23:35 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sat, 19 May 2012 23:35:23 +0000 (23:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157136 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaTemplate/delegating-constructors.cpp

index 9571a2684592236455f0645217748c4050f00581..676063ac0840cc07f085dc4cbc3c821e9043d26e 100644 (file)
@@ -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<Expr>(),
                                           InitRange.getEnd());
index e177b50375f010a76723235e2076305717d80c09..852b89d809fab4c27b86e3c1e92baf33ccd68172 100644 (file)
@@ -29,3 +29,21 @@ namespace PR10457 {
     Foo f(1, 1);
   }
 }
+
+namespace PR12890 {
+  class Document
+  {
+  public:
+      Document() = default;
+
+      template <class T>
+      explicit
+      Document(T&& t) : Document()
+      {
+      }
+  };
+  void f()
+  {
+      Document d(1);
+  }
+}