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
This commit is contained in:
Lexi Winter 2025-03-27 14:23:13 +00:00 committed by Warner Losh
parent 1ae6faf164
commit daf47b9ec9

View file

@ -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