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#48670: 27.2; cc-mode and constexpr if Date: Sun, 30 May 2021 16:29:17 +0000 Message-ID: References: <87lf8242gc.fsf@gmail.com> 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="2363"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, 48670@debbugs.gnu.org To: John Eivind Helset Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 30 18:30:17 2021 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 1lnOKO-0000SG-RA for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 May 2021 18:30:16 +0200 Original-Received: from localhost ([::1]:45690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnOKN-00070q-TP for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 May 2021 12:30:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnOKB-00070g-D4 for bug-gnu-emacs@gnu.org; Sun, 30 May 2021 12:30:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48705) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lnOKA-0006jd-Iq for bug-gnu-emacs@gnu.org; Sun, 30 May 2021 12:30:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lnOKA-0002zw-FU for bug-gnu-emacs@gnu.org; Sun, 30 May 2021 12:30:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 May 2021 16:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48670 X-GNU-PR-Package: emacs Original-Received: via spool by 48670-submit@debbugs.gnu.org id=B48670.162239218311474 (code B ref 48670); Sun, 30 May 2021 16:30:02 +0000 Original-Received: (at 48670) by debbugs.gnu.org; 30 May 2021 16:29:43 +0000 Original-Received: from localhost ([127.0.0.1]:60251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lnOJc-0002yh-PX for submit@debbugs.gnu.org; Sun, 30 May 2021 12:29:43 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:62030 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1lnOJY-0002yQ-VS for 48670@debbugs.gnu.org; Sun, 30 May 2021 12:29:27 -0400 Original-Received: (qmail 73190 invoked by uid 3782); 30 May 2021 16:29:18 -0000 Original-Received: from acm.muc.de (p2e5d5a0f.dip0.t-ipconnect.de [46.93.90.15]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 30 May 2021 18:29:17 +0200 Original-Received: (qmail 19695 invoked by uid 1000); 30 May 2021 16:29:17 -0000 Content-Disposition: inline In-Reply-To: <87lf8242gc.fsf@gmail.com> X-Submission-Agent: TMDA/1.3.x (Ph3nix) 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:207634 Archived-At: Hello, John. On Wed, May 26, 2021 at 05:08:03 +0200, John Eivind Helset wrote: > cc-mode has problems with constexpr-if-statements whose true-statement > is not a compound statement. > >From 'emacs -Q' open a buffer in cc-mode and compare the formatting of: > void f(){ > if(a == 4) > return 4; > else if(a == 3) > return 3; > else > return 2; > } > void f_constexpr(){ > if constexpr(a == 4) > return 4; > else if constexpr(a == 3) > return 3; > else > return 2; > } Thanks for taking the trouble to report this bug, and thanks even more for creating a minimal, easy to work with, test case. The bug has in fact already been fixed in the development version of Emacs, and should be getting released with Emacs 28.1, whenever that will happen. In the mean time, please apply the following patch to ..../emacs/lisp/progmodes/cc-engine.el, and then byte compile that file. Should you want any help with the patching or byte compilation, feel free to send me private email. --- cc-engine.el.orig 2021-05-30 16:08:48.855885223 +0000 +++ cc-engine.el 2021-05-30 16:16:47.785903083 +0000 @@ -1181,6 +1181,15 @@ ;; suitable error. (setq pre-stmt-found t) (throw 'loop nil)) + ;; Handle C++'s `constexpr', etc. + (if (save-excursion + (and (looking-at c-block-stmt-hangon-key) + (progn + (c-backward-syntactic-ws lim) + (c-safe (c-backward-sexp) t)) + (looking-at c-block-stmt-2-key) + (setq pos (point)))) + (goto-char pos)) (cond ;; Have we moved into a macro? ((and (not macro-start) > In GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.17.4) > of 2021-03-26 built on juergen > Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 > System Description: Arch Linux [ .... ] > -- > John Eivind Helset -- Alan Mackenzie (Nuremberg, Germany).