diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2019-01-04 16:58:14 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2019-01-04 16:58:14 +0000 |
commit | fb6deeb984d6d1dd16938c41a662bdafc969b745 (patch) | |
tree | b22b6b1562daaf1890eadb5f41f633f578bc0f0b /clang/lib/Sema/SemaDecl.cpp | |
parent | c2054144eec0d6ee9826a3ba7439bab219872c84 (diff) | |
download | bcm5719-llvm-fb6deeb984d6d1dd16938c41a662bdafc969b745.tar.gz bcm5719-llvm-fb6deeb984d6d1dd16938c41a662bdafc969b745.zip |
Refactor the way we handle diagnosing unused expression results.
Rather than sprinkle calls to DiagnoseUnusedExprResult() around in places where we want diagnostics, we now diagnose unused expression statements and full expressions in a more generic way when acting on the final expression statement. This results in more appropriate diagnostics for [[nodiscard]] where we were previously lacking them, such as when the body of a for loop is not a compound statement.
This patch fixes PR39837.
llvm-svn: 350404
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 80cafbedf5e..40b0ed37791 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -11204,9 +11204,9 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) { // struct T { S a, b; } t = { Temp(), Temp() } // // we should destroy the first Temp before constructing the second. - ExprResult Result = ActOnFinishFullExpr(Init, VDecl->getLocation(), - false, - VDecl->isConstexpr()); + ExprResult Result = + ActOnFinishFullExpr(Init, VDecl->getLocation(), + /*DiscardedValue*/ false, VDecl->isConstexpr()); if (Result.isInvalid()) { VDecl->setInvalidDecl(); return; |