From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#42270: 28.0.50; cc-mode indentation issue with attributes Date: Mon, 7 Sep 2020 12:04:45 +0200 Message-ID: <20200907100445.gf4puqrlt2mcju5k@Ergus> References: <20200708170358.sn4omf4vk3jlks4x.ref@ergus> <20200708170358.sn4omf4vk3jlks4x@ergus> <20200905121335.GA5479@ACM> Reply-To: Ergus Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11443"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 42270@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 07 12:06:16 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 1kFE2S-0002rn-BJ for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 07 Sep 2020 12:06:16 +0200 Original-Received: from localhost ([::1]:40284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kFE2R-0002vS-Af for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 07 Sep 2020 06:06:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFE2E-0002u8-LY for bug-gnu-emacs@gnu.org; Mon, 07 Sep 2020 06:06:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36572) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kFE2E-000055-Cb for bug-gnu-emacs@gnu.org; Mon, 07 Sep 2020 06:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kFE2E-0007LF-7h for bug-gnu-emacs@gnu.org; Mon, 07 Sep 2020 06:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ergus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 07 Sep 2020 10:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42270 X-GNU-PR-Package: emacs Original-Received: via spool by 42270-submit@debbugs.gnu.org id=B42270.159947310328141 (code B ref 42270); Mon, 07 Sep 2020 10:06:02 +0000 Original-Received: (at 42270) by debbugs.gnu.org; 7 Sep 2020 10:05:03 +0000 Original-Received: from localhost ([127.0.0.1]:48118 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFE1H-0007Jn-6T for submit@debbugs.gnu.org; Mon, 07 Sep 2020 06:05:03 -0400 Original-Received: from sonic304-56.consmr.mail.bf2.yahoo.com ([74.6.128.31]:40812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFE1E-0007JD-DK for 42270@debbugs.gnu.org; Mon, 07 Sep 2020 06:05:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1599473094; bh=qO65+Xwlbm6kaG2XLHPh9GWeiwQvjas/piFAobNT2yk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject; b=qGOyA0t2IA8k4mwQI2zwGjs0fFLSypOXI0Aa9OwgKcPYkz+ngnvg8nqXXYl9RasEvZ1V80XOYV5BMpngroq7RmAlTBPc2p5MTFpI9ydl3ai/HMLTACDzjyCuXNBCPiT2fz3IF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PSSTRDctUBVICgA69w Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.bf2.yahoo.com with HTTP; Mon, 7 Sep 2020 10:04:54 +0000 Original-Received: by smtp409.mail.bf1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 4de8408cb2580a8e147a9b7a31ec757f; Mon, 07 Sep 2020 10:04:50 +0000 (UTC) Content-Disposition: inline In-Reply-To: <20200905121335.GA5479@ACM> X-Mailer: WebService/1.1.16565 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Apache-HttpAsyncClient/4.1.4 (Java/11.0.7) 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:187418 Archived-At: Hi Alan: I will try it now and give you some feed back this week. Very thanks, On Sat, Sep 05, 2020 at 12:13:35PM +0000, Alan Mackenzie wrote: >Hello, Ergus. > >Thanks for the bug report. > >On Wed, Jul 08, 2020 at 19:03:58 +0200, Ergus wrote: >> Hi: > >> Working in C++ I am getting this indentation difference when arguments >> has attributes or not: > >> TaskDataAccesses(TaskDataAccessesInfo taskAccessInfo) >> : _lock(), >> _accesses(), >> _accessFragments(), _taskwaitFragments() >> { >> } > > >> TaskDataAccesses(__attribute__((unused)) TaskDataAccessesInfo taskAccessInfo) >> : _lock(), >> _accesses(), >> _accessFragments(), _taskwaitFragments() >> { >> } > >> The problem seems to be that in the first case the `:` indentation >> symbol (C-c C-o) is recognised as `member-init-intro` (correct) but in >> the second one it is detected as a `topmost-intro-cont` which is >> actually wrong. > >Yes, indeed. There were also problems with the fontification in similar >fragments, e.g.: > > TaskDataAccesses(foo((unused)) TaskDataAccessesInfo taskAccessInfo) > : _lock(), > _accesses(), > _accessFragments(), _taskwaitFragments() > { > } > >, where typing into "foo" removed the fontification from >"Task...unused))", which got replaced on the next redisplay (e.g. after >typing M-x). > >I think the patch below fixes all these problems. Would you please apply >it, rebuild CC Mode, load it, and try it out on your real source code. A >fairly thorough test would be appreciated, here. Then please let me know >if the bug is actually fixed, and whether there are any "strange things" >happening. Thanks! > >> Best, >> Ergus > >> In GNU Emacs 28.0.50 (build 10, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars) >> of 2020-07-07 built on ergus >> Repository revision: df3ece9d2ed61c9526dbf718e3c96d72bd53dccb >> Repository branch: master >> System Description: Debian GNU/Linux 10 (buster) > > > >diff -r 877c4ad9dae8 cc-engine.el >--- a/cc-engine.el Sat Jul 04 16:23:06 2020 +0000 >+++ b/cc-engine.el Sat Sep 05 11:53:51 2020 +0000 >@@ -2243,7 +2243,7 @@ > > ((and c-opt-cpp-prefix > (looking-at c-noise-macro-name-re)) >- ;; Skip over a noise macro. >+ ;; Skip over a noise macro without parens. > (goto-char (match-end 1)) > (not (eobp))) > >@@ -9141,6 +9141,12 @@ > (catch 'is-function > (while > (progn >+ (while >+ (cond >+ ((looking-at c-decl-hangon-key) >+ (c-forward-keyword-clause 1)) >+ ((looking-at c-noise-macro-with-parens-name-re) >+ (c-forward-noise-clause)))) > (if (eq (char-after) ?\)) > (throw 'is-function t)) > (setq cdd-got-type (c-forward-type)) >@@ -9789,6 +9795,16 @@ > (save-excursion > (goto-char after-paren-pos) > (c-forward-syntactic-ws) >+ (progn >+ (while >+ (cond >+ ((and >+ c-opt-cpp-prefix >+ (looking-at c-noise-macro-with-parens-name-re)) >+ (c-forward-noise-clause)) >+ ((looking-at c-decl-hangon-key) >+ (c-forward-keyword-clause 1)))) >+ t) > (or (c-forward-type) > ;; Recognize a top-level typeless > ;; function declaration in C. >diff -r 877c4ad9dae8 cc-mode.el >--- a/cc-mode.el Sat Jul 04 16:23:06 2020 +0000 >+++ b/cc-mode.el Sat Sep 05 11:53:51 2020 +0000 >@@ -2236,7 +2236,8 @@ > (defun c-fl-decl-end (pos) > ;; If POS is inside a declarator, return the end of the token that follows > ;; the declarator, otherwise return nil. POS being in a literal does not >- ;; count as being in a declarator (on pragmatic grounds). >+ ;; count as being in a declarator (on pragmatic grounds). POINT is not >+ ;; preserved. > (goto-char pos) > (let ((lit-start (c-literal-start)) > enclosing-attribute pos1) >@@ -2249,12 +2250,31 @@ > (let ((lim (save-excursion > (and (c-beginning-of-macro) > (progn (c-end-of-macro) (point)))))) >- (when (and (c-forward-declarator lim) >- (or (not (eq (char-after) ?\()) >- (c-go-list-forward nil lim)) >- (eq (c-forward-token-2 1 nil lim) 0)) >- (c-backward-syntactic-ws) >- (point))))))) >+ (and (c-forward-declarator lim) >+ (if (eq (char-after) ?\() >+ (and >+ (c-go-list-forward nil lim) >+ (progn (c-forward-syntactic-ws lim) >+ (not (eobp))) >+ (progn >+ (if (looking-at c-symbol-char-key) >+ ;; Deal with baz (foo((bar)) type var), where >+ ;; foo((bar)) is not semantically valid. The result >+ ;; must be after var). >+ (and >+ (goto-char pos) >+ (setq pos1 (c-on-identifier)) >+ (goto-char pos1) >+ (progn >+ (c-backward-syntactic-ws) >+ (eq (char-before) ?\()) >+ (c-fl-decl-end (1- (point)))) >+ (c-backward-syntactic-ws) >+ (point)))) >+ (and (progn (c-forward-syntactic-ws lim) >+ (not (eobp))) >+ (c-backward-syntactic-ws) >+ (point))))))))) > > (defun c-change-expand-fl-region (beg end old-len) > ;; Expand the region (c-new-BEG c-new-END) to an after-change font-lock >diff -r 877c4ad9dae8 cc-vars.el >--- a/cc-vars.el Sat Jul 04 16:23:06 2020 +0000 >+++ b/cc-vars.el Sat Sep 05 11:53:51 2020 +0000 >@@ -1668,7 +1668,8 @@ > like \"INLINE\" which are syntactic noise. Such a macro/extension is complete > in itself, never having parentheses. All these names must be syntactically > valid identifiers. Alternatively, this variable may be a regular expression >-which matches the names of such macros. >+which matches the names of such macros, in which case it must have a submatch >+1 which matches the actual noise macro name. > > If you change this variable's value, call the function > `c-make-noise-macro-regexps' to set the necessary internal variables (or do >@@ -1683,7 +1684,8 @@ > which optionally have arguments in parentheses, and which expand to nothing. > All these names must be syntactically valid identifiers. These are recognized > by CC Mode only in declarations. Alternatively, this variable may be a >-regular expression which matches the names of such macros. >+regular expression which matches the names of such macros, in which case it >+must have a submatch 1 which matches the actual noise macro name. > > If you change this variable's value, call the function > `c-make-noise-macro-regexps' to set the necessary internal variables (or do > > >-- >Alan Mackenzie (Nuremberg, Germany).