forked from OSchip/llvm-project
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 <rdar://problem/11974632>, although the result is still rather unsatisfactory. llvm-svn: 163871
This commit is contained in:
parent
1ec4a5e190
commit
6d149412c8
|
@ -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<InitListExpr>(InitExpr) && isStdInitializerList(FD->getType(), 0)) {
|
||||
Diag(FD->getLocation(), diag::warn_dangling_std_initializer_list)
|
||||
<< /*at end of ctor*/1 << InitExpr->getSourceRange();
|
||||
|
|
|
@ -304,3 +304,19 @@ namespace init_list_default {
|
|||
};
|
||||
B b {}; // calls default constructor
|
||||
}
|
||||
|
||||
|
||||
// <rdar://problem/11974632>
|
||||
namespace rdar11974632 {
|
||||
struct X {
|
||||
X(const X&) = delete;
|
||||
X(int);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct Y {
|
||||
X x{1};
|
||||
};
|
||||
|
||||
Y<int> yi;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue