From 80b0fb04a6e9ec51e0bd7e021d49a3fa21eaa1cc Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Thu, 19 Oct 2017 15:58:58 +0000 Subject: Fix nodiscard for volatile references As reported here https://bugs.llvm.org/show_bug.cgi?id=34988 [[nodiscard]] warnings were not being suppressed for volatile-ref return values. Differential Revision: https://reviews.llvm.org/D39075 llvm-svn: 316166 --- clang/lib/AST/Expr.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'clang/lib/AST/Expr.cpp') diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index e8aa8f3d33d..6cda82b2b0c 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -2298,7 +2298,8 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc, const DeclRefExpr *DRE = dyn_cast(CE->getSubExpr()->IgnoreParens()); if (!(DRE && isa(DRE->getDecl()) && - cast(DRE->getDecl())->hasLocalStorage())) { + cast(DRE->getDecl())->hasLocalStorage()) && + !isa(CE->getSubExpr()->IgnoreParens())) { return CE->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx); } -- cgit v1.2.3