[cfe-commits] r157136 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaTemplate/delegating-constructors.cpp

Eli Friedman eli.friedman at gmail.com
Sat May 19 16:35:23 PDT 2012


Author: efriedma
Date: Sat May 19 18:35:23 2012
New Revision: 157136

URL: http://llvm.org/viewvc/llvm-project?rev=157136&view=rev
Log:
Make delegating initializers use a similar codepath to base initializers in dependent contexts.  PR12890.


Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/SemaTemplate/delegating-constructors.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=157136&r1=157135&r2=157136&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat May 19 18:35:23 2012
@@ -2234,6 +2234,16 @@
   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());

Modified: cfe/trunk/test/SemaTemplate/delegating-constructors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/delegating-constructors.cpp?rev=157136&r1=157135&r2=157136&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/delegating-constructors.cpp (original)
+++ cfe/trunk/test/SemaTemplate/delegating-constructors.cpp Sat May 19 18:35:23 2012
@@ -29,3 +29,21 @@
     Foo f(1, 1);
   }
 }
+
+namespace PR12890 {
+  class Document
+  {
+  public:
+      Document() = default;
+
+      template <class T>
+      explicit
+      Document(T&& t) : Document()
+      {
+      }
+  };
+  void f()
+  {
+      Document d(1);
+  }
+}





More information about the cfe-commits mailing list