[flang-commits] [flang] [flang] Allow C style comments in continuation lines (PR #214336)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Thu Aug 20 05:00:38 PDT 2026
eugeneepshteyn wrote:
Below are AI code review comments that are worth looking into, especially those about adding more tests:
Two asks before this lands, both about making the decided behavior stick:
1. **Please add tests pinning the semantics this discussion just settled.** Right now no test covers the flipped shapes, so a future prescanner change could silently undo this decision. Worth pinning: rejection of `/* c */ &` (and `/* c */ & ! comment`), acceptance of `/* c */ &= 6` (unparses as `i=6`), and two more shapes I found that flip from reject to accept with this PR — a directive continuation with a leading comment, e.g.
```fortran
!$omp parallel do &
/* c */ !$omp private(i)
```
(a hard "bad character" scan error on `main`, accepted + warned with this PR), and a mid-statement resumption `i = 1 &` / `/* c */ & + 1`.
2. **Please expand the PR description** (it becomes the commit message): this change intentionally rejects previously-accepted code (`/* c */ &`) and newly accepts previously-rejected shapes, with the space-spelling-consistency rationale and gfortran/ifx agreement. A short line in `flang/docs/ReleaseNotes.md` about the acceptance change would help users who hit the new error after upgrading. The `flang/docs/Extensions.md` sentence about classic C comments could also mention that a directive following a comment on the same line is treated as commentary.
Smaller follow-up-grade observations, not blocking:
- Comment-only continuation lines (e.g. `i&` / `/* c */` / `= 5`, including the shape from #129455) are newly accepted with no `-pedantic` warning at all, while comments with code on the same line do warn. That matches the long-standing behavior for standalone comment lines (they never warned), so a uniform fix in the comment-line classification path seems like good follow-up material rather than something for this PR — but it's worth a mention in the description.
- Only the first of several comments on one continuation line gets the portability warning (`/* a */ /* b */ = &` warned twice before, once now). Fine as one-warning-per-line policy, but maybe worth a comment in the code.
- In `SkipWhiteSpaceIncludingEmptyMacros`, passing a null `cComment` now *disables* comment skipping rather than just expressing disinterest in the result — a doc comment on the declaration (or a separate overload) would keep future callers from misreading `/*cComment=*/nullptr` as "don't report".
- Test 02 nits: the two `ERROR:` checks don't pin the warning locations or exact count, and `-fopenmp` isn't needed by that source.
https://github.com/llvm/llvm-project/pull/214336
More information about the flang-commits
mailing list