On Wed, May 21, 2025 at 11:31:01PM +0200, Alejandro Colomar wrote:
> The preexisting ones are not just the outermost ones. The preexisting
> code was
>
> (in_sizeof
> ? "sizeof"
> : (in_typeof ? "typeof" : "alignof")));
>
> The only pattern I can find in that code is wrapping every ?:
> subexpression in (). I would find not doing so for the last one I'm
> adding inconsistent with it. On the other hand, I would agree that
> limiting it to just the outermost ones would be more readable, but that
> would mean removing existing ()s. So can you please confirm that I
> should remove the existing inner ()?
I think
warning_at (loc, OPT_Wc___compat,
"defining type in %qs expression is invalid in C++",
in_sizeof ? "sizeof" : in_typeof ? "typeof"
: in_alignof ? "alignof" : "_Countof");
or say
(in_sizeof ? "sizeof"
: in_typeof ? "typeof"
: in_alignof ? "alignof"
: "_Countof"));
or that without the extra () would look better.
Those are the styles used elsewhere, e.g.
alias.cc- sizey = (!MEM_P (rtly) ? poly_int64 (GET_MODE_SIZE (GET_MODE (rtly)))
alias.cc: : MEM_SIZE_KNOWN_P (rtly) ? MEM_SIZE (rtly)
alias.cc- : -1);
or
cfgexpand.cc- allows_reg ? EXPAND_NORMAL
cfgexpand.cc: : allows_mem ? EXPAND_MEMORY
cfgexpand.cc- : EXPAND_INITIALIZER);
or
combine.cc- inner = simplify_binary_operation (code == MINUS ? PLUS
combine.cc: : code == DIV ? MULT
combine.cc- : code,
combine.cc- mode, inner_op0,
inner_op1);
etc.
Jakub