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

Douglas Gregor dgregor at apple.com
Thu Sep 22 16:04:35 PDT 2011


Author: dgregor
Date: Thu Sep 22 18:04:35 2011
New Revision: 140350

URL: http://llvm.org/viewvc/llvm-project?rev=140350&view=rev
Log:
Don't finalize checking of base and member initializers for a
constructor template. Fixes PR10457.

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

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=140350&r1=140349&r2=140350&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Sep 22 18:04:35 2011
@@ -2373,7 +2373,7 @@
                                CXXCtorInitializer **Initializers,
                                unsigned NumInitializers,
                                bool AnyErrors) {
-  if (Constructor->getDeclContext()->isDependentContext()) {
+  if (Constructor->isDependentContext()) {
     // Just store the initializers as written, they will be checked during
     // instantiation.
     if (NumInitializers > 0) {

Added: cfe/trunk/test/SemaTemplate/delegating-constructors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/delegating-constructors.cpp?rev=140350&view=auto
==============================================================================
--- cfe/trunk/test/SemaTemplate/delegating-constructors.cpp (added)
+++ cfe/trunk/test/SemaTemplate/delegating-constructors.cpp Thu Sep 22 18:04:35 2011
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++0x %s -verify 
+
+namespace PR10457 {
+
+  class string
+  {
+    string(const char* str, unsigned);
+
+  public:
+    template <unsigned N>
+    string(const char (&str)[N])
+      : string(str) {} // expected-error{{constructor for 'string<6>' creates a delegation cycle}}
+  };
+
+  void f() {
+    string s("hello");
+  }
+}





More information about the cfe-commits mailing list