-
Notifications
You must be signed in to change notification settings - Fork 345
Fix #pragma warning not working with multifile modules #7942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 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>
- 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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow. I don't understand how it figure it out...
@csyonghe this got automatically pulled out of the merge queue for reason I don't fully understand. Seems like the build is just stuck on that machine. |
The
#pragma warning
directives were not working correctly when modules included multiple files via__include
. Pragma warning states (likedisable
,push
,pop
) were being lost when processing subsequent included files, causing warnings to appear even when they should have been suppressed.Root Cause
The issue was in
slang-preprocessor.cpp
where a newWarningStateTracker
was created for each file processed by the preprocessor. When__include
directives processed additional files, they created fresh warning state trackers, losing the pragma warning state from previously processed files.Example of the Issue
Consider this module structure:
Before this fix, warning 30856 would incorrectly appear in
impl2.slang
even though it was disabled inimpl1.slang
.Solution
Modified the preprocessor to check if the
DiagnosticSink
already has aWarningStateTracker
before creating a new one. This ensures pragma warning states persist across all files in a module:Testing
Added comprehensive regression tests covering:
__include
scenariosAll existing pragma and warning-related tests continue to pass.
Fixes #7941.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.