From 5f632cd204b7a85f3a97b6c316c5a34f9fc8193e Mon Sep 17 00:00:00 2001 From: Ronan Date: Fri, 25 Apr 2025 00:48:37 +0200 Subject: Implemented #pragma warning (#6748) * Implemented #pragma warning Based on https://learn.microsoft.com/en-us/cpp/preprocessor/warning?view=msvc-170 * Make #pragma warning work with #includes. - SourceLoc are not sorted by inclusion order. - Construct a mapping from SourceLoc to "absolute locations" that are sorted by inclusion order (roughly represents a location in a raw file with all #include resolved). - The absolute location can be used in the pragma warning timeline * Added preprocessor #pragma warning tests. - Fixed #pragma warning (push / pop) SourceLoc - Fixed unused directiveLoc in #pragma warning parsing * #pragma warning: Added some comments and fixed some typos * Cleaned #pragma warning preprocessor implementation. --------- Co-authored-by: Yong He --- source/compiler-core/slang-diagnostic-sink.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'source/compiler-core/slang-diagnostic-sink.cpp') diff --git a/source/compiler-core/slang-diagnostic-sink.cpp b/source/compiler-core/slang-diagnostic-sink.cpp index f9a7d9c88..28a98266a 100644 --- a/source/compiler-core/slang-diagnostic-sink.cpp +++ b/source/compiler-core/slang-diagnostic-sink.cpp @@ -612,10 +612,20 @@ bool DiagnosticSink::diagnoseImpl( return true; } -Severity DiagnosticSink::getEffectiveMessageSeverity(DiagnosticInfo const& info) +Severity DiagnosticSink::getEffectiveMessageSeverity( + DiagnosticInfo const& info, + SourceLoc const& location) { Severity effectiveSeverity = info.severity; + if (effectiveSeverity <= Severity::Warning && m_sourceWarningStateTracker) + { + effectiveSeverity = m_sourceWarningStateTracker->consumeWarningSeverity( + location, + info.id, + effectiveSeverity); + } + Severity* pSeverityOverride = m_severityOverrides.tryGetValue(info.id); // See if there is an override @@ -639,7 +649,7 @@ bool DiagnosticSink::diagnoseImpl( DiagnosticArg const* args) { // Override the severity in the 'info' structure to pass it further into formatDiagnostics - info.severity = getEffectiveMessageSeverity(info); + info.severity = getEffectiveMessageSeverity(info, pos); if (info.severity == Severity::Disable) return false; -- cgit v1.2.3