[clang] [clang] Restrict -Wnrvo to C++ code only. (PR #157059)

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 19 02:36:49 PST 2026


Javier =?utf-8?q?Mu=C3=B1oz?= Kirschberg
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/157059 at github.com>


================
@@ -0,0 +1,41 @@
+// RUN: %clang -std=c23 -Wnrvo -Xclang -verify %s
+// expected-no-diagnostics
+
+#include <stdlib.h>
----------------
zmodem wrote:

I don't think we should include `<stdlib.h>` (there may not be one).

Also I don't think you need it if you simplify the test. For example:

```
struct s { int x; };
struct s foo(int x) {
         struct s a = { 1 }, b = { 2 };
         if (x == 0)
                 return a; // -Wnrvo
         return b;
}
```

https://github.com/llvm/llvm-project/pull/157059


More information about the cfe-commits mailing list