From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#23312: 25.0.92; C++: Incorrect indentation of enum values inside a class Date: 22 Apr 2016 20:02:08 -0000 Organization: muc.de e.V. Message-ID: <20160422200208.40627.qmail@mail.muc.de> References: NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1461355405 29236 80.91.229.3 (22 Apr 2016 20:03:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 22 Apr 2016 20:03:25 +0000 (UTC) Cc: 23312@debbugs.gnu.org To: Anders Lindgren Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 22 22:03:15 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1athIF-0002pC-Q5 for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 Apr 2016 22:03:11 +0200 Original-Received: from localhost ([::1]:38943 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1athIF-0001Ol-1D for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 Apr 2016 16:03:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1athIB-0001Mb-Kj for bug-gnu-emacs@gnu.org; Fri, 22 Apr 2016 16:03:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1athIA-00036f-IB for bug-gnu-emacs@gnu.org; Fri, 22 Apr 2016 16:03:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59352) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1athI6-00036B-QQ; Fri, 22 Apr 2016 16:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1athI6-0000xh-HM; Fri, 22 Apr 2016 16:03:02 -0400 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: Fri, 22 Apr 2016 20:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23312 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 23312-submit@debbugs.gnu.org id=B23312.14613553323640 (code B ref 23312); Fri, 22 Apr 2016 20:03:02 +0000 Original-Received: (at 23312) by debbugs.gnu.org; 22 Apr 2016 20:02:12 +0000 Original-Received: from localhost ([127.0.0.1]:43456 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1athHH-0000we-RP for submit@debbugs.gnu.org; Fri, 22 Apr 2016 16:02:12 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:15397) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1athHG-0000wV-09 for 23312@debbugs.gnu.org; Fri, 22 Apr 2016 16:02:10 -0400 Original-Received: (qmail 40628 invoked by uid 3782); 22 Apr 2016 20:02:08 -0000 In-Reply-To: X-Newsgroups: gnu.emacs.bug User-Agent: tin/2.3.1-20141224 ("Tallant") (UNIX) (FreeBSD/10.3-RELEASE (amd64)) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:116684 Archived-At: Hello, Anders. In article you wrote: > [-- text/plain, encoding 7bit, charset: UTF-8, 101 lines --] > In C++ mode in Emacs 25.0.92, enums inside classes are incorrectly indented. > For example (emacs -Q): > class MyClass > { > public: > enum Id > { > kAlpha, > kBeta // Incorrect indentation. > In Emacs 24.5, the "kAlpha" and "kBeta" were aligned, as expected. This was caused by an enhancement (for C++ typed enums) which failed properly to check its occurrence. I think the following patch fixes the bug. Would you please try it out in real code, and either confirm it works properly, or tell me what is still faulty. Thanks! diff --git a/.gitignore b/.gitignore index 7c8b743..c1d9067 100644 --- a/.gitignore +++ b/.gitignore @@ -261,7 +261,10 @@ ChangeLog [0-9]*.txt .dir-locals?.el /vc-dwim-log-* +*.diff +.gitattributes +*.acm # Built by 'make install'. etc/emacs.tmpdesktop diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 62bc236..1be438f 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -8928,11 +8928,11 @@ c-cheap-inside-bracelist-p (not (looking-at "="))))) b-pos))) -(defun c-backward-colon-prefixed-type () - ;; We're at the token after what might be a type prefixed with a colon. Try - ;; moving backward over this type and the colon. On success, return t and - ;; leave point before colon; on failure, leave point unchanged. Will clobber - ;; match data. +(defun c-backward-typed-enum-colon () + ;; We're at a "{" which might be the opening brace of a enum which is + ;; strongly typed (by a ":" followed by a type). If this is the case, leave + ;; point before the colon and return t. Otherwise leave point unchanged and return nil. + ;; Match data will be clobbered. (let ((here (point)) (colon-pos nil)) (save-excursion @@ -8941,7 +8941,10 @@ c-backward-colon-prefixed-type (or (not (looking-at "\\s)")) (c-go-up-list-backward)) (cond - ((eql (char-after) ?:) + ((and (eql (char-after) ?:) + (save-excursion + (c-backward-syntactic-ws) + (c-on-identifier))) (setq colon-pos (point)) (forward-char) (c-forward-syntactic-ws) @@ -8965,7 +8968,7 @@ c-backward-over-enum-header (let ((here (point)) up-sexp-pos before-identifier) (when c-recognize-post-brace-list-type-p - (c-backward-colon-prefixed-type)) + (c-backward-typed-enum-colon)) (while (and (eq (c-backward-token-2) 0) > -- Anders Lindgren > In GNU Emacs 25.0.92.1 (i686-w64-mingw32) > of 2016-03-21 built on LAPHROAIG > Windowing system distributor 'Microsoft Corp.', version 6.1.7601 > Configured using: > 'configure --host=i686-w64-mingw32 --without-dbus > --without-compress-install CFLAGS=-static' -- Alan Mackenzie (Nuremberg, Germany).