GNU bug report logs -
#27130
c-mode indentation mistreats structs in function arguments
Previous Next
Full log
View this message in rfc822 format
Alan Mackenzie <acm <at> muc.de> writes:
> Hello, Lars.
>
> On Mon, Nov 30, 2020 at 12:11:56 +0100, Lars Ingebrigtsen wrote:
>> Sam Pagenkopf <ssaammp <at> gmail.com> writes:
>
>> > In emacs 25.2.1.
>
>> > Relevant code:
>
>> > draw_add(&battle.draw, (Drawn){
>> > .kind = DRAW_RECT,
>> > .size = {40,24},
>> > .pos.border = {
>> > .align = {ALIGN_LEFT, ALIGN_TOP},
>> > .dist = 3
>> > }
>> > }
>> > );
>
>> > My guess is that it's reading (Drawn){...} as a statement, and the , as
>> > the (,) C operator.
>
>> I'm not sure how this should be indented (as I didn't even know that
>> that was valid C). But that does look wrong, in any case. (I've
>> confirmed that it indents it the same way in Emacs 28.)
>
>> Alan?
>
> That's strange. In my Emacs 28 copy, I get this indentation:
>
> int main ()
> {
> draw_add(&battle.draw, (Drawn){
> .kind = DRAW_RECT,
> .size = {40,24},
> .pos.border = {
> .align = {ALIGN_LEFT, ALIGN_TOP},
> .dist = 3
> }
> }
> );
> }
>
> , which apart from the closing parenthesis being indented too far, looks
> basically OK.
I was thinking the next-to-last } was in a somewhat odd place (the one
that closes the Drawn), but on the other hand I don't really know where
else it should be. On the third hand...
int main ()
{
draw_add(&battle.draw, (Drawn)
{
.kind = DRAW_RECT,
.size = {40,24},
.pos.border = {
.align = {ALIGN_LEFT, ALIGN_TOP},
.dist = 3
}
}
);
}
Now the end brace looks correct to me. So perhaps it should be indented
the same way in the original case? That is:
int main ()
{
draw_add(&battle.draw, (Drawn) {
.kind = DRAW_RECT,
.size = {40,24},
.pos.border = {
.align = {ALIGN_LEFT, ALIGN_TOP},
.dist = 3
}
}
);
}
I'm talking about the braces only -- as you point out, the end
parenthesis is a different matter.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
This bug report was last modified 4 years and 196 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.