[cfe-commits] r163919 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/cxx0x-delegating-ctors.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Fri Sep 14 11:21:10 PDT 2012
Author: rsmith
Date: Fri Sep 14 13:21:10 2012
New Revision: 163919
URL: http://llvm.org/viewvc/llvm-project?rev=163919&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/cxx0x-delegating-ctors.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=163919&r1=163918&r2=163919&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Sep 14 13:21:10 2012
@@ -3346,11 +3346,10 @@
} 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]);
Modified: cfe/trunk/test/SemaCXX/cxx0x-delegating-ctors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-delegating-ctors.cpp?rev=163919&r1=163918&r2=163919&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-delegating-ctors.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-delegating-ctors.cpp Fri Sep 14 13:21:10 2012
@@ -33,7 +33,9 @@
//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
More information about the cfe-commits
mailing list