[PATCH] D124534: Add a diagnostic for line directive of a gnu extension

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 29 11:25:25 PDT 2022

aaron.ballman added inline comments.

Comment at: clang/lib/Lex/PPDirectives.cpp:1356
+    PP.Diag(FlagTok, diag::ext_pp_gnu_line_directive);
   } else if (FlagVal == 2) {
ken-matsui wrote:
> aaron.ballman wrote:
> > I speculate that this change is wrong.
> > 
> > The goal here is to diagnose any time there's a GNU line marker and now we're only trigging the diagnostic when the line marker's value is 1; that misses diagnostics when the marker value is something else.
> > 
> > That's why I suggested warning each place we return `false` from this function -- those are the situations when the line marker is syntactically correct and we're going to make use of it in the caller. (We don't want to warn about use of a line marker when we're going to generate an error anyway.)
> @aaron.ballman 
> Thank you!
> Just to confirm, do I need to remove the call of `Diag` after `GetLineValue` and put `Diag`s into all branches of returning `false` in this function?
> If so, I think putting `Diag` after the call of this function would be better.
> If so, I think putting Diag after the call of this function would be better.

You are correct and I agree, good suggestion!

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list