From: Douglas Gregor Date: Fri, 14 Sep 2012 04:20:37 +0000 (+0000) Subject: As we do with base and member initializers in a dependent class, delay X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dd084276526db1d53edf2b6fc8c4c8187e6ab540;p=clang As we do with base and member initializers in a dependent class, delay type checking for non-static data member initializers in a dependent class, because our ASTs lose too much information to when type-checking an initializer. Fixes , although the result is still rather unsatisfactory. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163871 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 5ee28da4ef..7c97453d6f 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1702,7 +1702,11 @@ Sema::ActOnCXXInClassMemberInitializer(Decl *D, SourceLocation InitLoc, } ExprResult Init = InitExpr; - if (!FD->getType()->isDependentType() && !InitExpr->isTypeDependent()) { + if (!FD->getType()->isDependentType() && !InitExpr->isTypeDependent() && + !FD->getDeclContext()->isDependentContext()) { + // Note: We don't type-check when we're in a dependent context, because + // the initialization-substitution code does not properly handle direct + // list initialization. We have the same hackaround for ctor-initializers. if (isa(InitExpr) && isStdInitializerList(FD->getType(), 0)) { Diag(FD->getLocation(), diag::warn_dangling_std_initializer_list) << /*at end of ctor*/1 << InitExpr->getSourceRange(); diff --git a/test/SemaCXX/cxx0x-initializer-constructor.cpp b/test/SemaCXX/cxx0x-initializer-constructor.cpp index 223e140ffc..a657ec81a1 100644 --- a/test/SemaCXX/cxx0x-initializer-constructor.cpp +++ b/test/SemaCXX/cxx0x-initializer-constructor.cpp @@ -304,3 +304,19 @@ namespace init_list_default { }; B b {}; // calls default constructor } + + +// +namespace rdar11974632 { + struct X { + X(const X&) = delete; + X(int); + }; + + template + struct Y { + X x{1}; + }; + + Y yi; +}