[clang] [clang-repl] Suppress [[nodiscard]] warnings for REPL printed express (PR #178661)
Vassil Vassilev via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 11 01:32:58 PST 2026
================
@@ -5721,6 +5721,10 @@ Parser::DeclGroupPtrTy Parser::ParseTopLevelStmtDecl() {
Tok.getAnnotationValue() != nullptr) {
ConsumeAnnotationToken();
TLSD->setSemiMissing();
+ } else if (R.isUsable()) {
+ // Semicolon is present, so the value is being discarded.
+ // Re-diagnose [[nodiscard]] warnings that were suppressed during parsing.
+ Actions.DiagnoseUnusedExprResult(R.get(), diag::warn_unused_expr);
----------------
vgvassilev wrote:
I don't think we need this branch here. Why the other change is not sufficient?
https://github.com/llvm/llvm-project/pull/178661
More information about the cfe-commits
mailing list