mbenfield added a comment.

So it seems there are 3 issues here:

1. local variables declared extern should not trigger this warning. I'll fix 
this.

2. Should `x` in this code trigger the warning:

  int x;
  int y = (x = 0);

These are essentially the "false positives" reported in the Linux kernel. I 
find it questionable to consider these "false positives"; it seems to me that 
`x` is not really used. But gcc's behavior is to not trigger here so maybe 
following it is best.

3. If `x` above should not trigger the warning, it might be difficult to detect 
this case with an AST walk using the current data. Would it be acceptable to 
add a bit to `VarDecl` or `Decl` indicating whether it's ever //read// (not 
just referenced), which could then be set, maybe in `Sema::ActOnFinishFullExpr` 
? This would then prevent the need for the new AST walk altogether. (it seems 
gcc has such a bit)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to