diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-05-03 00:28:49 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-05-03 00:28:49 +0000 |
commit | 56f548bbbb7e4387a69708f70724d00e9e076153 (patch) | |
tree | 4315d3ec71dde0f77eb12325d870bfac89e8927c /unittests/Basic | |
parent | 386800d3a0134e44aceba44ad1cf4528e2e8ccb5 (diff) |
[modules] Round-trip -Werror flag through explicit module build.
The intent for an explicit module build is that the diagnostics produced within
the module are those that were configured when the module was built, not those
that are enabled within a user of the module. This includes diagnostics that
don't actually show up until the module is used (for instance, diagnostics
produced during template instantiation and weird cases like -Wpadded).
We serialized and restored the diagnostic state for individual warning groups,
but previously did not track the state for flags like -Werror and -Weverything,
which are implemented as separate bits rather than as part of the diagnostics
mapping information.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301992 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Basic')
-rw-r--r-- | unittests/Basic/DiagnosticTest.cpp | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/unittests/Basic/DiagnosticTest.cpp b/unittests/Basic/DiagnosticTest.cpp index 4ffa0837bd..0111b17247 100644 --- a/unittests/Basic/DiagnosticTest.cpp +++ b/unittests/Basic/DiagnosticTest.cpp @@ -46,27 +46,30 @@ TEST(DiagnosticTest, suppressAndTrap) { EXPECT_FALSE(Diags.hasUnrecoverableErrorOccurred()); } -// Check that FatalsAsErrors works as intended -TEST(DiagnosticTest, fatalsAsErrors) { - DiagnosticsEngine Diags(new DiagnosticIDs(), - new DiagnosticOptions, - new IgnoringDiagConsumer()); - Diags.setFatalsAsError(true); +// Check that SuppressAfterFatalError works as intended +TEST(DiagnosticTest, suppressAfterFatalError) { + for (unsigned Suppress = 0; Suppress != 2; ++Suppress) { + DiagnosticsEngine Diags(new DiagnosticIDs(), + new DiagnosticOptions, + new IgnoringDiagConsumer()); + Diags.setSuppressAfterFatalError(Suppress); - // Diag that would set UncompilableErrorOccurred and ErrorOccurred. - Diags.Report(diag::err_target_unknown_triple) << "unknown"; + // Diag that would set UnrecoverableErrorOccurred and ErrorOccurred. + Diags.Report(diag::err_cannot_open_file) << "file" << "error"; - // Diag that would set UnrecoverableErrorOccurred and ErrorOccurred. - Diags.Report(diag::err_cannot_open_file) << "file" << "error"; + // Diag that would set FatalErrorOccurred + // (via non-note following a fatal error). + Diags.Report(diag::warn_mt_message) << "warning"; - // Diag that would set FatalErrorOccurred - // (via non-note following a fatal error). - Diags.Report(diag::warn_mt_message) << "warning"; + EXPECT_TRUE(Diags.hasErrorOccurred()); + EXPECT_TRUE(Diags.hasFatalErrorOccurred()); + EXPECT_TRUE(Diags.hasUncompilableErrorOccurred()); + EXPECT_TRUE(Diags.hasUnrecoverableErrorOccurred()); - EXPECT_TRUE(Diags.hasErrorOccurred()); - EXPECT_FALSE(Diags.hasFatalErrorOccurred()); - EXPECT_TRUE(Diags.hasUncompilableErrorOccurred()); - EXPECT_TRUE(Diags.hasUnrecoverableErrorOccurred()); + // The warning should be emitted and counted only if we're not suppressing + // after fatal errors. + EXPECT_EQ(Diags.getNumWarnings(), Suppress ? 0u : 1u); + } } } |