From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#27130: c-mode indentation mistreats structs in function arguments Date: Mon, 30 Nov 2020 17:04:34 +0000 Message-ID: References: <87zh2zaykj.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34255"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Sam Pagenkopf , 27130@debbugs.gnu.org, acm@muc.de To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 30 18:11:46 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kjmiI-0008o0-6J for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Nov 2020 18:11:46 +0100 Original-Received: from localhost ([::1]:54116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kjmiH-0001IP-7U for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Nov 2020 12:11:45 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kjmbn-0001xJ-2c for bug-gnu-emacs@gnu.org; Mon, 30 Nov 2020 12:05:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44954) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kjmbm-0006uJ-PI; Mon, 30 Nov 2020 12:05:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kjmbm-0002y1-KX; Mon, 30 Nov 2020 12:05:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Mon, 30 Nov 2020 17:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27130 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: confirmed Original-Received: via spool by 27130-submit@debbugs.gnu.org id=B27130.160675589911392 (code B ref 27130); Mon, 30 Nov 2020 17:05:02 +0000 Original-Received: (at 27130) by debbugs.gnu.org; 30 Nov 2020 17:04:59 +0000 Original-Received: from localhost ([127.0.0.1]:56500 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kjmbU-0002xQ-7Y for submit@debbugs.gnu.org; Mon, 30 Nov 2020 12:04:59 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:59162 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1kjmbS-0002xB-Eh for 27130@debbugs.gnu.org; Mon, 30 Nov 2020 12:04:43 -0500 Original-Received: (qmail 88650 invoked by uid 3782); 30 Nov 2020 17:04:35 -0000 Original-Received: from acm.muc.de (p4fe15abb.dip0.t-ipconnect.de [79.225.90.187]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Mon, 30 Nov 2020 18:04:34 +0100 Original-Received: (qmail 10024 invoked by uid 1000); 30 Nov 2020 17:04:34 -0000 Content-Disposition: inline In-Reply-To: <87zh2zaykj.fsf@gnus.org> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:194659 Archived-At: Hello, Lars. On Mon, Nov 30, 2020 at 12:11:56 +0100, Lars Ingebrigtsen wrote: > Sam Pagenkopf 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. Possibly, one might want the .kind line indented one space further (it is indented 2 * c-basic-offset from the draw_add on the previous line). C-c C-s on that line gives the following analysis: ((arglist-cont-nonempty 19 27) (brace-list-intro 19)) . C-c C-s on the following line should give ((brace-list-entry 63)) , where 63 is the position of the . in .kind. This is correct. In fact, something in this area was corrected in the last three or four years, The closing paren is lined up by c-align-arglist-close-under-paren, which contains a bit of DWIMery which misfires here, causing the ) to be indented c-basic-offset from the first character on the line opening the construct (here the draw_add line). This DWIMery has also recently misfired on a C++ file, so I think I'll have to modernise c-align-arglist-close-under-paren to be more discerning. > -- > (domestic pets only, the antidote for overdose, milk.) > bloggy blog: http://lars.ingebrigtsen.no -- Alan Mackenzie (Nuremberg, Germany).