diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -631,11 +631,18 @@ StringRef Content(ContentBegin, ContentEnd-ContentBegin); size_t CPos = 0; size_t FPos; + bool Append = false; while ((FPos = Content.find(NewlineStr, CPos)) != StringRef::npos) { D.Text += Content.substr(CPos, FPos-CPos); D.Text += '\n'; CPos = FPos + NewlineStr.size(); + Append = true; } + // Previous while loop did not add line after final newline. If there is + // more text after the newline, append it here. + if (Append && CPos != Content.size()) + D.Text += Content.substr(CPos, Content.size()); + if (D.Text.empty()) D.Text.assign(ContentBegin, ContentEnd); diff --git a/clang/test/SemaCXX/references.cpp b/clang/test/SemaCXX/references.cpp --- a/clang/test/SemaCXX/references.cpp +++ b/clang/test/SemaCXX/references.cpp @@ -90,7 +90,7 @@ int& okay; // expected-note{{reference member 'okay' will never be initialized}} }; -struct C : B, A { }; // expected-warning {{direct base 'A' is inaccessible due to ambiguity:\n struct C -> struct B -> struct A\nstruct C -> struct A}} +struct C : B, A { }; // expected-warning {{direct base 'A' is inaccessible due to ambiguity:\n struct C -> struct B -> struct A\n struct C -> struct A}} void test7(C& c) { A& a1 = c; // expected-error {{ambiguous conversion from derived class 'C' to base class 'A':}}