Skip to content

pp_line: do not swallow #line with negative deltas - #49

Open
sreekotay wants to merge 1 commit into
TinyCC:mobfrom
sreekotay:pr/pp-line-negative-delta
Open

pp_line: do not swallow #line with negative deltas#49
sreekotay wants to merge 1 commit into
TinyCC:mobfrom
sreekotay:pr/pp-line-negative-delta

Conversation

@sreekotay

Copy link
Copy Markdown

Summary

  • pp_line takes the short-newline swallow path when level == 0 && f->line_ref && d < 8.
  • Negative d (a #line that resumes an earlier line after a large synthetic injection) still matches d < 8, but while (d > 0) is a no-op, so the directive is silently dropped and line tracking drifts.
  • Restrict the swallow to d >= 0 && d < 8 so negative deltas fall through to the normal #line / # N emission.

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 N with N smaller than the current physical line by 8+.

Test plan

  • tcc -E a file that does a large injection then #line back to a small line number; confirm the #line (or # N) appears in the output
  • Existing preprocess / diagnostic tests still pass

Made with Cursor

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
sreekotay force-pushed the pr/pp-line-negative-delta branch from 4d2ad22 to 34d7c2b Compare August 11, 2026 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant