[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
Thu Apr 28 11:01:55 PDT 2022


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:431
+def ext_pp_gnu_line_directive : Extension<
+  "this style of line directive is a GNU extension">;
+
----------------
Oops, I missed this last time around, but we need this to be in a warning group as well.

I think you should add: `def GNULineMarker : DiagGroup<"gnu-line-marker">;` to `DiagnosticGroups.td` and then add `GNULineMarker` to the `GNU` warning group.

Then here, you can make these changes.


================
Comment at: clang/lib/Lex/PPDirectives.cpp:1404
   PP.Lex(FlagTok);
   if (FlagTok.is(tok::eod)) return false;
 
----------------
I think you need to add another call to `Diag()` here.


================
Comment at: clang/test/Misc/warning-flags.c:93
 
-CHECK: Number in -Wpedantic (not covered by other -W flags): 27
+CHECK: Number in -Wpedantic (not covered by other -W flags): 28
----------------
Oops, I missed this before -- two lines up, it also says this count should never grow. This should be fixed by my suggestion to add it to a warning group.


================
Comment at: clang/test/Preprocessor/line-directive.c:119
+# 115 "main" // expected-warning {{this style of line directive is a GNU extension}}
 # 116 "enter-1" 1
 # 117 "enter-2" 1
----------------
These should also get the warning.


================
Comment at: clang/test/Preprocessor/line-directive.c:33
 # 42 "foo" 2 // expected-error {{invalid line marker flag '2': cannot pop empty include stack}}
 # 42 "foo" 1 3  // enter
 # 42 "foo" 2 3  // exit
----------------
aaron.ballman wrote:
> As should this form.
It looks like this form isn't getting the warning we'd expect.


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