summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorCopilot <198982749+Copilot@users.noreply.github.com>2025-08-04 17:13:19 -0700
committerGitHub <noreply@github.com>2025-08-05 00:13:19 +0000
commit301ffb1944a01d33d0b82c135f3c4a86e80fde2e (patch)
tree94d0f6f6253ed21c17150f03cd5c421a66824435 /source/slang
parent41314741d9bfca95abba40e58720b4ce2f2653dd (diff)
Fix #pragma warning not working with multifile modules (#7942)
* Initial plan * Fix pragma warning not working with multifile modules - Check if DiagnosticSink already has a WarningStateTracker before creating new one - This preserves pragma warning state across __include'd files - Add regression tests for multifile pragma warnings Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add additional test cases for nested pragma warnings - Test nested __include scenarios with pragma warning directives - Verify pragma warnings work correctly with multiple levels of includes Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-preprocessor.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/source/slang/slang-preprocessor.cpp b/source/slang/slang-preprocessor.cpp
index b29fa2716..a0e80473d 100644
--- a/source/slang/slang-preprocessor.cpp
+++ b/source/slang/slang-preprocessor.cpp
@@ -4878,9 +4878,14 @@ TokenList preprocessSource(
desc.contentAssistInfo = &linkage->contentAssistInfo.preprocessorInfo;
}
- preprocessor::WarningStateTracker* wst =
- new preprocessor::WarningStateTracker(desc.sourceManager);
- desc.sink->setSourceWarningStateTracker(wst);
+ // Only create a new WarningStateTracker if the sink doesn't already have one.
+ // This ensures pragma warning states are preserved across included files.
+ if (!desc.sink->getSourceWarningStateTracker())
+ {
+ preprocessor::WarningStateTracker* wst =
+ new preprocessor::WarningStateTracker(desc.sourceManager);
+ desc.sink->setSourceWarningStateTracker(wst);
+ }
return preprocessSource(file, desc, outDetectedLanguage, outLanguageVersion);
}