pp_line: do not swallow #line with negative deltas - #49
Open
sreekotay wants to merge 1 commit into
Open
Conversation
The short-newline path used `d < 8`, which also matches negative deltas. The inner `while (d > 0)` is then a no-op, so a user #line that resumes an earlier line after a large injection is dropped and diagnostics drift. Restrict the swallow to `d >= 0 && d < 8`.
sreekotay
force-pushed
the
pr/pp-line-negative-delta
branch
from
August 11, 2026 05:08
4d2ad22 to
34d7c2b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pp_linetakes the short-newline swallow path whenlevel == 0 && f->line_ref && d < 8.d(a#linethat resumes an earlier line after a large synthetic injection) still matchesd < 8, butwhile (d > 0)is a no-op, so the directive is silently dropped and line tracking drifts.d >= 0 && d < 8so negative deltas fall through to the normal#line/# Nemission.Context
Hit this while preserving user-source line numbers after prepending generated declarations (Concurrent-C). Reproducible with any preprocess (
-E/LINE_MACRO_OUTPUT) flow that emits#line NwithNsmaller than the current physical line by 8+.Test plan
tcc -Ea file that does a large injection then#lineback to a small line number; confirm the#line(or# N) appears in the outputMade with Cursor