[PATCH] D109981: [Diagnostics] Don't drop a statically set NoWarningAsError flag during option processing

Wolfgang Pieb via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 10 16:39:10 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd789ea713372: [Diagnostics] Don't drop a statically set NoWarningAsError flag during option… (authored by wolfgangp).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D109981?vs=373255&id=398778#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109981/new/

https://reviews.llvm.org/D109981

Files:
  clang/lib/Basic/Diagnostic.cpp
  clang/test/Lexer/pragma-message.c


Index: clang/test/Lexer/pragma-message.c
===================================================================
--- clang/test/Lexer/pragma-message.c
+++ clang/test/Lexer/pragma-message.c
@@ -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}}
Index: clang/lib/Basic/Diagnostic.cpp
===================================================================
--- clang/lib/Basic/Diagnostic.cpp
+++ clang/lib/Basic/Diagnostic.cpp
@@ -374,6 +374,12 @@
   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()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109981.398778.patch
Type: text/x-patch
Size: 1591 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220111/611f24b2/attachment.bin>


More information about the cfe-commits mailing list