GNU bug report logs - #27130
c-mode indentation mistreats structs in function arguments

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs,cc-mode; Reported by: Sam Pagenkopf <ssaammp@HIDDEN>; Keywords: confirmed; dated Mon, 29 May 2017 16:01:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 27130 <at> debbugs.gnu.org:


Received: (at 27130) by debbugs.gnu.org; 30 Nov 2020 17:04:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 30 12:04:59 2020
Received: from localhost ([127.0.0.1]:56500 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kjmbU-0002xQ-7Y
	for submit <at> debbugs.gnu.org; Mon, 30 Nov 2020 12:04:59 -0500
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 <acm@HIDDEN>) id 1kjmbS-0002xB-Eh
 for 27130 <at> debbugs.gnu.org; Mon, 30 Nov 2020 12:04:43 -0500
Received: (qmail 88650 invoked by uid 3782); 30 Nov 2020 17:04:35 -0000
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
Received: (qmail 10024 invoked by uid 1000); 30 Nov 2020 17:04:34 -0000
Date: Mon, 30 Nov 2020 17:04:34 +0000
To: Lars Ingebrigtsen <larsi@HIDDEN>
Subject: Re: bug#27130: c-mode indentation mistreats structs in function
 arguments
Message-ID: <X8UmIl+Yp8A/R17n@ACM>
References: <CAKiGDcO6hedSbWEP=VLq5U-7PunPewX_2JD_qm_Hs6W4NJH6+A@HIDDEN>
 <87zh2zaykj.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <87zh2zaykj.fsf@HIDDEN>
X-Delivery-Agent: TMDA/1.1.12 (Macallan)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 27130
Cc: Sam Pagenkopf <ssaammp@HIDDEN>, 27130 <at> debbugs.gnu.org, acm@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Lars.

On Mon, Nov 30, 2020 at 12:11:56 +0100, Lars Ingebrigtsen wrote:
> Sam Pagenkopf <ssaammp@HIDDEN> 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).




Information forwarded to bug-gnu-emacs@HIDDEN, bug-cc-mode@HIDDEN:
bug#27130; Package emacs,cc-mode. Full text available.
Added tag(s) confirmed. Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 27130 <at> debbugs.gnu.org:


Received: (at 27130) by debbugs.gnu.org; 30 Nov 2020 11:12:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 30 06:12:08 2020
Received: from localhost ([127.0.0.1]:53718 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kjh6G-0000aX-1S
	for submit <at> debbugs.gnu.org; Mon, 30 Nov 2020 06:12:08 -0500
Received: from quimby.gnus.org ([95.216.78.240]:34826)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1kjh6E-0000Zu-13
 for 27130 <at> debbugs.gnu.org; Mon, 30 Nov 2020 06:12:06 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=7FORfGmMsb9r5zqW2JGTXEs37eLt7VoMFcHR5fErNZg=; b=SJuNRhQG3385cvvcja+I1vzzU1
 cJuUJlsBKZfvFpZVLqlEeJOciIee/ZqeUkupEwwPtgncXHUnjV2s/DdX9W4Q6BpJeWHx967ktG+13
 G88erMlnqi6WAFo9mvRQd5M/Z5k6rGywYraRblFHl9vsDBl8cZjAlNbsbBQ8pLnVje7o=;
Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1kjh65-00086j-M6; Mon, 30 Nov 2020 12:12:00 +0100
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Sam Pagenkopf <ssaammp@HIDDEN>
Subject: Re: bug#27130: c-mode indentation mistreats structs in function
 arguments
References: <CAKiGDcO6hedSbWEP=VLq5U-7PunPewX_2JD_qm_Hs6W4NJH6+A@HIDDEN>
X-Now-Playing: Yukihiro Takahashi's _Saravah!_: "C'est Si Bon"
Date: Mon, 30 Nov 2020 12:11:56 +0100
In-Reply-To: <CAKiGDcO6hedSbWEP=VLq5U-7PunPewX_2JD_qm_Hs6W4NJH6+A@HIDDEN>
 (Sam Pagenkopf's message of "Mon, 29 May 2017 08:33:35 -0500")
Message-ID: <87zh2zaykj.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Sam Pagenkopf <ssaammp@HIDDEN> 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 [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 27130
Cc: 27130 <at> debbugs.gnu.org, Alan Mackenzie <acm@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Sam Pagenkopf <ssaammp@HIDDEN> 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?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN, bug-cc-mode@HIDDEN:
bug#27130; Package emacs,cc-mode. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 29 May 2017 16:00:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 29 12:00:10 2017
Received: from localhost ([127.0.0.1]:43530 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dFN5W-0003Zn-E0
	for submit <at> debbugs.gnu.org; Mon, 29 May 2017 12:00:10 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39009)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ssaammp@HIDDEN>) id 1dFKnp-0008Te-38
 for submit <at> debbugs.gnu.org; Mon, 29 May 2017 09:33:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ssaammp@HIDDEN>) id 1dFKnj-00082w-4v
 for submit <at> debbugs.gnu.org; Mon, 29 May 2017 09:33:39 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:60537)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <ssaammp@HIDDEN>) id 1dFKnj-00082s-1W
 for submit <at> debbugs.gnu.org; Mon, 29 May 2017 09:33:39 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:58204)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <ssaammp@HIDDEN>) id 1dFKni-0001Ez-3j
 for bug-gnu-emacs@HIDDEN; Mon, 29 May 2017 09:33:38 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ssaammp@HIDDEN>) id 1dFKnh-00082H-AJ
 for bug-gnu-emacs@HIDDEN; Mon, 29 May 2017 09:33:38 -0400
Received: from mail-qt0-x231.google.com ([2607:f8b0:400d:c0d::231]:32918)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <ssaammp@HIDDEN>) id 1dFKnh-00081p-6X
 for bug-gnu-emacs@HIDDEN; Mon, 29 May 2017 09:33:37 -0400
Received: by mail-qt0-x231.google.com with SMTP id t26so49945614qtg.0
 for <bug-gnu-emacs@HIDDEN>; Mon, 29 May 2017 06:33:36 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=BpZuKGUbvHkFno06/fX2U7Yb5FvVyefMZXPo0af6ce0=;
 b=A2KrnvokFOu31/eCMcGS02YgwS4kQS+Wpy+hycGwnOj/KPNbI1vsr8FlucunFESqt2
 nysOKZYjGxRSKT78d995WSdu/LdW+lxHUU4WyeC2t+fMGblExda1kt98p44rPn0F21y4
 hKKMFFO0x94oqN07SDNYrPh0rfWjne74JYPeFle6/UOvVpJjJCQUkEWqjESbEh/pDvt/
 bD4YfIWQ+CRvIsi9yHv4tXImsHU3Vp2lZIYHbTMZmFx6L80sI0wdtIafOlWJN/X67w53
 fGzCL7zcWiV5zF8uXThyjwk8FjOpGomeweu/a19gtCjCnNVJOkpTi91Mf2WBwPhYqnk9
 vqNA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=BpZuKGUbvHkFno06/fX2U7Yb5FvVyefMZXPo0af6ce0=;
 b=eLM1gnC6QL2PtwzDdd1hiyXd8HB7h3HGFPL+G8r4MztFNun3JgAeTCpyVmW2SbH+nd
 CquXYmamXNCY2wwCENafPRRX0UncclrhZyQPPTWejYk1f9LZyjgLYznz8/GNuHxM0eUe
 uiaDF1EUOQr30kOObjx+/O+bqw5AAzQs1ZJ67oNRYG5TCR759So3/RqQixPGx0g/czu3
 f8/eCPmIExlUYHkyjXjEyKWaKEMHR9AButrNPhWPMPjZ0lt2kurTyaFbRrmjj9mfTnsz
 Ai0qqLQQGhjyv1uY81k/qUfkbFOoweeQvwlKYIsYTNrIwSL3sTMq1dMMel85lTRNzqSm
 bMaw==
X-Gm-Message-State: AODbwcDHNmDSuRCtKxkBoCNb02mt/nUWNaLsQI6exNIy3xJKsPT+agky
 06P2VxdnUcqpiatVMUfhJCcUrKxegLB3
X-Received: by 10.237.35.34 with SMTP id h31mr17283502qtc.148.1496064816240;
 Mon, 29 May 2017 06:33:36 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.237.61.113 with HTTP; Mon, 29 May 2017 06:33:35 -0700 (PDT)
From: Sam Pagenkopf <ssaammp@HIDDEN>
Date: Mon, 29 May 2017 08:33:35 -0500
Message-ID: <CAKiGDcO6hedSbWEP=VLq5U-7PunPewX_2JD_qm_Hs6W4NJH6+A@HIDDEN>
Subject: c-mode indentation mistreats structs in function arguments
To: bug-gnu-emacs@HIDDEN
Content-Type: multipart/alternative; boundary="001a113c2366eede520550a9bbc5"
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Mon, 29 May 2017 12:00:09 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)

--001a113c2366eede520550a9bbc5
Content-Type: text/plain; charset="UTF-8"

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.

--001a113c2366eede520550a9bbc5
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: base64

PGRpdiBkaXI9Imx0ciI+SW4gZW1hY3MgMjUuMi4xLjxicj48ZGl2Pjxicj5SZWxldmFudCBjb2Rl
Ojxicj48ZGl2Pjxicj7CoMKgwqAgZHJhd19hZGQoJmFtcDtiYXR0bGUuZHJhdywgKERyYXduKXs8
YnI+wqDCoMKgwqDCoMKgwqDCoMKgwqDCoCAua2luZCA9IERSQVdfUkVDVCw8YnI+wqDCoMKgwqDC
oMKgwqDCoMKgwqDCoMKgwqDCoMKgIC5zaXplID0gezQwLDI0fSw8YnI+wqDCoMKgwqDCoMKgwqDC
oMKgwqDCoMKgwqDCoMKgIC5wb3MuYm9yZGVyID0gezxicj7CoMKgwqDCoMKgwqDCoMKgwqDCoMKg
wqDCoMKgwqAgLmFsaWduID0ge0FMSUdOX0xFRlQsIEFMSUdOX1RPUH0sPGJyPsKgwqDCoMKgwqDC
oMKgwqDCoMKgwqDCoMKgwqDCoCAuZGlzdCA9IDM8YnI+wqDCoMKgwqDCoMKgwqDCoMKgwqDCoCB9
PGJyPsKgwqDCoMKgwqDCoMKgIH08YnI+wqDCoMKgwqDCoMKgwqAgKTs8YnI+PGJyPk15IGd1ZXNz
IGlzIHRoYXQgaXQmIzM5O3MgcmVhZGluZyAoRHJhd24pey4uLn0gYXMgYSBzdGF0ZW1lbnQsIGFu
ZCB0aGUgLCBhczxicj50aGUgKCwpIEMgb3BlcmF0b3IuPC9kaXY+PC9kaXY+PC9kaXY+DQo=
--001a113c2366eede520550a9bbc5--




Acknowledgement sent to Sam Pagenkopf <ssaammp@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#27130; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 30 Nov 2020 17:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.