[PATCH] D39075: Fix nodiscard for volatile references

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 18 15:50:46 PDT 2017


erichkeane added inline comments.


================
Comment at: lib/AST/Expr.cpp:2302
+              cast<VarDecl>(DRE->getDecl())->hasLocalStorage()) &&
+            !isa<CallExpr>(CE->getSubExpr()->IgnoreParens())) {
           return CE->getSubExpr()->isUnusedResultAWarning(WarnE, Loc,
----------------
aaron.ballman wrote:
> Does this properly handle calls through function pointers (which usually have implicit casts)?
> ```
> [[nodiscard]] volatile char &(*fp)();
> void g() {
>   (void)fp(); // No diagnostic here, either?
> }
> ```
I added this test, and it seems to work correctly.  Patch with additional test incoming.


https://reviews.llvm.org/D39075





More information about the cfe-commits mailing list