================
@@ -239,6 +239,15 @@ void DiagnoseUnused(Sema &S, const Expr *E, 
std::optional<unsigned> DiagID) {
   if (S.isUnevaluatedContext())
     return;
 
+  // In incremental processing mode (REPL), expressions inside TopLevelStmtDecl
+  // without a semicolon will have their values printed by the value printing
+  // mechanism. The result is therefore "used" and we should not warn about
+  // [[nodiscard]] attributes.
+  if (S.PP.isIncrementalProcessingEnabled()) {
+    if (isa<TopLevelStmtDecl>(S.CurContext))
+      return;
+  }
----------------
vgvassilev wrote:

I suspect that we should mark the expression as used when we have missing 
semicolon in the interpreter. Can we try that instead of having a special case 
here?

https://github.com/llvm/llvm-project/pull/178661
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to