зеркало из https://github.com/microsoft/clang-1.git
Don't check member and base initializers if the constructor is dependent.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80211 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
5c36fb22d9
Коммит
8d4c5ea0ee
|
@ -947,40 +947,46 @@ void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl,
|
|||
Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
|
||||
return;
|
||||
}
|
||||
llvm::DenseMap<void*, CXXBaseOrMemberInitializer *>Members;
|
||||
bool err = false;
|
||||
for (unsigned i = 0; i < NumMemInits; i++) {
|
||||
CXXBaseOrMemberInitializer *Member =
|
||||
static_cast<CXXBaseOrMemberInitializer*>(MemInits[i]);
|
||||
void *KeyToMember = GetKeyForMember(Member);
|
||||
CXXBaseOrMemberInitializer *&PrevMember = Members[KeyToMember];
|
||||
if (!PrevMember) {
|
||||
PrevMember = Member;
|
||||
continue;
|
||||
}
|
||||
if (FieldDecl *Field = Member->getMember())
|
||||
Diag(Member->getSourceLocation(),
|
||||
diag::error_multiple_mem_initialization)
|
||||
<< Field->getNameAsString();
|
||||
else {
|
||||
Type *BaseClass = Member->getBaseClass();
|
||||
assert(BaseClass && "ActOnMemInitializers - neither field or base");
|
||||
Diag(Member->getSourceLocation(),
|
||||
diag::error_multiple_base_initialization)
|
||||
<< BaseClass->getDesugaredType(true);
|
||||
}
|
||||
Diag(PrevMember->getSourceLocation(), diag::note_previous_initializer)
|
||||
<< 0;
|
||||
err = true;
|
||||
}
|
||||
|
||||
if (err)
|
||||
return;
|
||||
if (!Constructor->isDependentContext()) {
|
||||
llvm::DenseMap<void*, CXXBaseOrMemberInitializer *>Members;
|
||||
bool err = false;
|
||||
for (unsigned i = 0; i < NumMemInits; i++) {
|
||||
CXXBaseOrMemberInitializer *Member =
|
||||
static_cast<CXXBaseOrMemberInitializer*>(MemInits[i]);
|
||||
void *KeyToMember = GetKeyForMember(Member);
|
||||
CXXBaseOrMemberInitializer *&PrevMember = Members[KeyToMember];
|
||||
if (!PrevMember) {
|
||||
PrevMember = Member;
|
||||
continue;
|
||||
}
|
||||
if (FieldDecl *Field = Member->getMember())
|
||||
Diag(Member->getSourceLocation(),
|
||||
diag::error_multiple_mem_initialization)
|
||||
<< Field->getNameAsString();
|
||||
else {
|
||||
Type *BaseClass = Member->getBaseClass();
|
||||
assert(BaseClass && "ActOnMemInitializers - neither field or base");
|
||||
Diag(Member->getSourceLocation(),
|
||||
diag::error_multiple_base_initialization)
|
||||
<< BaseClass->getDesugaredType(true);
|
||||
}
|
||||
Diag(PrevMember->getSourceLocation(), diag::note_previous_initializer)
|
||||
<< 0;
|
||||
err = true;
|
||||
}
|
||||
|
||||
if (err)
|
||||
return;
|
||||
}
|
||||
|
||||
BuildBaseOrMemberInitializers(Context, Constructor,
|
||||
reinterpret_cast<CXXBaseOrMemberInitializer **>(MemInits),
|
||||
NumMemInits);
|
||||
|
||||
if (Constructor->isDependentContext())
|
||||
return;
|
||||
|
||||
if (Diags.getDiagnosticLevel(diag::warn_base_initialized) ==
|
||||
Diagnostic::Ignored &&
|
||||
Diags.getDiagnosticLevel(diag::warn_field_initialized) ==
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// RUN: clang-cc -fsyntax-only -verify %s
|
||||
|
||||
template<typename T> struct A {
|
||||
A() : j(10), i(10) { }
|
||||
|
||||
int i;
|
||||
int j;
|
||||
};
|
||||
|
||||
template<typename T> struct B : A<T> {
|
||||
B() : A<T>() { }
|
||||
};
|
||||
|
Загрузка…
Ссылка в новой задаче