aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-09-22 23:04:35 +0000
committerDouglas Gregor <dgregor@apple.com>2011-09-22 23:04:35 +0000
commitd836c0d379403a173ae1ede56fcad034d04a1e34 (patch)
tree42372aaa557ea94fcce7779abb0a275d5d2cc74e
parentfdde47061d8ff0b481414ccf69ebdc47c2216274 (diff)
Don't finalize checking of base and member initializers for a
constructor template. Fixes PR10457. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140350 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDeclCXX.cpp2
-rw-r--r--test/SemaTemplate/delegating-constructors.cpp18
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 6f14e61630..616f798594 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -2373,7 +2373,7 @@ bool Sema::SetCtorInitializers(CXXConstructorDecl *Constructor,
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) {
diff --git a/test/SemaTemplate/delegating-constructors.cpp b/test/SemaTemplate/delegating-constructors.cpp
new file mode 100644
index 0000000000..5c7d85f6ed
--- /dev/null
+++ b/test/SemaTemplate/delegating-constructors.cpp
@@ -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");
+ }
+}