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

Ken Matsui via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 29 09:12:10 PDT 2022


ken-matsui added inline comments.


================
Comment at: clang/lib/Lex/PPDirectives.cpp:1356
+
+    PP.Diag(FlagTok, diag::ext_pp_gnu_line_directive);
   } else if (FlagVal == 2) {
----------------
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.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124534/new/

https://reviews.llvm.org/D124534



More information about the cfe-commits mailing list