summaryrefslogtreecommitdiff
path: root/source/compiler-core/slang-diagnostic-sink.cpp
diff options
context:
space:
mode:
authorRonan <ro.cailleau@gmail.com>2025-04-25 00:48:37 +0200
committerGitHub <noreply@github.com>2025-04-24 15:48:37 -0700
commit5f632cd204b7a85f3a97b6c316c5a34f9fc8193e (patch)
tree7dc74fbe8c80870a4c485bbaa5765ff379914779 /source/compiler-core/slang-diagnostic-sink.cpp
parentc7ecf3039d2cc8680f1ea5f4bee2d13521ae34f7 (diff)
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 <yonghe@outlook.com>
Diffstat (limited to 'source/compiler-core/slang-diagnostic-sink.cpp')
-rw-r--r--source/compiler-core/slang-diagnostic-sink.cpp14
1 files changed, 12 insertions, 2 deletions
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;