forked from OSchip/llvm-project
When diagnosing multiple mem-initializers in a delegating ctor, point to the delegating initializer, not to the first initializer. For good measure, also highlight the other initializer.
llvm-svn: 163919
This commit is contained in:
parent
d7ffdecec1
commit
21f06f0fcb
|
@ -3346,11 +3346,10 @@ void Sema::ActOnMemInitializers(Decl *ConstructorDecl,
|
|||
} else {
|
||||
assert(Init->isDelegatingInitializer());
|
||||
// This must be the only initializer
|
||||
if (i != 0 || NumMemInits > 1) {
|
||||
Diag(MemInits[0]->getSourceLocation(),
|
||||
if (NumMemInits != 1) {
|
||||
Diag(Init->getSourceLocation(),
|
||||
diag::err_delegating_initializer_alone)
|
||||
<< MemInits[0]->getSourceRange();
|
||||
HadError = true;
|
||||
<< Init->getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
|
||||
// We will treat this as being the only initializer.
|
||||
}
|
||||
SetDelegatingInitializer(Constructor, MemInits[i]);
|
||||
|
|
|
@ -33,7 +33,9 @@ foo::foo (const float &f) : foo(&f) { //expected-error{{creates a delegation cyc
|
|||
//expected-note{{which delegates to}}
|
||||
}
|
||||
|
||||
foo::foo (char) : i(3), foo(3) { // expected-error{{must appear alone}}
|
||||
foo::foo (char) :
|
||||
i(3),
|
||||
foo(3) { // expected-error{{must appear alone}}
|
||||
}
|
||||
|
||||
// This should not cause an infinite loop
|
||||
|
|
Loading…
Reference in New Issue