git: daf47b9ec9ed - main - style.9: relax "return (value)" requirement for C++
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 12 Jun 2025 00:29:03 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=daf47b9ec9ed360dfdff6769ae4d0c2c16972552
commit daf47b9ec9ed360dfdff6769ae4d0c2c16972552
Author: Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2025-03-27 14:23:13 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-06-12 00:21:44 +0000
style.9: relax "return (value)" requirement for C++
consider the following C++ code:
struct S { int a, b; };
S f() { return {1, 2}; }
according to style(9), the return statement should be formatted as:
return ({1, 2});
however, this is not valid C++ code and will not compile.
add an exception to style(9) to cover this case.
Reviewed by: imp, emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/1623
Closes: https://github.com/freebsd/freebsd-src/pull/1623
---
share/man/man9/style.9 | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/share/man/man9/style.9 b/share/man/man9/style.9
index 5542a9685c46..484b4f144b2e 100644
--- a/share/man/man9/style.9
+++ b/share/man/man9/style.9
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd February 18, 2025
+.Dd March 27, 2025
.Dt STYLE 9
.Os
.Sh NAME
@@ -766,7 +766,8 @@ to any pointer type.
.Pp
Values in
.Ic return
-statements should be enclosed in parentheses.
+statements should be enclosed in parentheses where possible.
+For example, parentheses cannot be used if the value is a C++ braced-init-list.
.Pp
Use
.Xr err 3