forked from OSchip/llvm-project
[Diagnostics] Don't drop a statically set NoWarningAsError flag during option processing
When a -W<diag> option is given on the command line, and the corresponding diagnostic has the NoWarnOnError flag set, prevent the flag from being dropped when the severity is reevaluated. This fixes PR51837. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D109981
This commit is contained in:
parent
1d3964d2ad
commit
d789ea7133
|
@ -374,6 +374,12 @@ void DiagnosticsEngine::setSeverity(diag::kind Diag, diag::Severity Map,
|
|||
DiagnosticMapping Mapping = makeUserMapping(Map, L);
|
||||
Mapping.setUpgradedFromWarning(WasUpgradedFromWarning);
|
||||
|
||||
// Make sure we propagate the NoWarningAsError flag from an existing
|
||||
// mapping (which may be the default mapping).
|
||||
DiagnosticMapping &Info = GetCurDiagState()->getOrAddMapping(Diag);
|
||||
Mapping.setNoWarningAsError(Info.hasNoWarningAsError() ||
|
||||
Mapping.hasNoWarningAsError());
|
||||
|
||||
// Common case; setting all the diagnostics of a group in one place.
|
||||
if ((L.isInvalid() || L == DiagStatesByLoc.getCurDiagStateLoc()) &&
|
||||
DiagStatesByLoc.getCurDiagState()) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* Test pragma message directive from
|
||||
http://msdn.microsoft.com/en-us/library/x7dkzch2.aspx */
|
||||
|
||||
// message: Sends a string literal to the standard output without terminating
|
||||
// the compilation.
|
||||
// #pragma message(messagestring)
|
||||
|
@ -8,6 +7,7 @@
|
|||
// #pragma message messagestring
|
||||
//
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -Werror %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -Werror -W#pragma-messages %s
|
||||
#define STRING2(x) #x
|
||||
#define STRING(x) STRING2(x)
|
||||
#pragma message(":O I'm a message! " STRING(__LINE__)) // expected-warning {{:O I'm a message! 13}}
|
||||
|
|
Loading…
Reference in New Issue