From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Herman@debbugs.gnu.org, =?UTF-8?Q?G=C3=A9za?= Newsgroups: gmane.emacs.bugs Subject: bug#69293: 30.0.50; cc-mode doesn't support "if consteval" Date: Mon, 25 Mar 2024 10:37:14 +0100 Message-ID: <87frwe7io7.fsf@gmail.com> References: <877ciyga48.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13173"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 69293@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 25 18:16:25 2024 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 1ronvt-0003CR-5a for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 25 Mar 2024 18:16:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ronvZ-00017A-DM; Mon, 25 Mar 2024 13:16:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ronvX-00015S-Sk for bug-gnu-emacs@gnu.org; Mon, 25 Mar 2024 13:16:03 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ronvX-0002H9-AG for bug-gnu-emacs@gnu.org; Mon, 25 Mar 2024 13:16:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ronvW-00066W-5F for bug-gnu-emacs@gnu.org; Mon, 25 Mar 2024 13:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Herman@debbugs.gnu.org, =?UTF-8?Q?G=C3=A9za?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 Mar 2024 17:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69293 X-GNU-PR-Package: emacs Original-Received: via spool by 69293-submit@debbugs.gnu.org id=B69293.171138694323409 (code B ref 69293); Mon, 25 Mar 2024 17:16:02 +0000 Original-Received: (at 69293) by debbugs.gnu.org; 25 Mar 2024 17:15:43 +0000 Original-Received: from localhost ([127.0.0.1]:36098 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ronvC-00065U-TS for submit@debbugs.gnu.org; Mon, 25 Mar 2024 13:15:43 -0400 Original-Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]:51280) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ronv9-00065D-Uq for 69293@debbugs.gnu.org; Mon, 25 Mar 2024 13:15:42 -0400 Original-Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a46f0da1b4fso591599366b.2 for <69293@debbugs.gnu.org>; Mon, 25 Mar 2024 10:15:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711386934; x=1711991734; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:in-reply-to:date :subject:cc:to:from:references:from:to:cc:subject:date:message-id :reply-to; bh=sDQD9hDZD93dI5hxqsTADYYGwaCoWpIQ36lLq1FdcA8=; b=LmgjQp2sCVw77ANz75D67kCHDzwJWT5EoYl3Zf2mfuGxNiJeEK1wtYK0A+j2YNH35S muphtLy4UfmIoRl2/pRmJTgiED8p3HoNkBUsZBInJccnd4uq3Wi0ci+ansEkmhzg+Hjj xaLOtNtwQEKbcjuAz1LfxJIcewkFFrNMfq6+IE6K9hSqSfYilp9V/21rKq6qzmKOypbi i7peQg8t4NrQNCoCYeEnJbDbLXuFhkGJOYjKSRdI2kZVv+5ufQJfmR28ewxHhOGiA1hv jWbC8KByaza4NhJVa3Rk64OG0MmwDtKKS41rk3MLI1lOoA0Ig4jWziU8+Z4UC5oh1jIL A4iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711386934; x=1711991734; h=content-transfer-encoding:mime-version:message-id:in-reply-to:date :subject:cc:to:from:references:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=sDQD9hDZD93dI5hxqsTADYYGwaCoWpIQ36lLq1FdcA8=; b=qy4nhvAnXDdh2Fb512IWVNe7PSZmjgyErdABtg0l89exA6G73qdZOA4XFEIk6KQV2O govjnZIuRk9wRBVDsUlED06Qzz9YloGQ9hGG72rw+PFDHfJdzJabFfSHffTg515gSiSu UfTqfyUZL0Ea/Z1/+BSzp3wEcSNHOSmhuY4e9lljBtof61Es61Q4BOTWx2VftErQYZcV dEWE030N0f/F31LO3Qsoy2XaHdqktM/q/Xf/ALPJtxvlf8ifC5G1N/sE29f5zmIayo7h rtcWyvkZTKrZfxnm9OLcM4CtmWoRpGqfTWpQcH1nFpIacOKlilDAX1iSblX2QVTGGBd5 J23Q== X-Gm-Message-State: AOJu0Yy0l7nvXe/2lKhI6IV/MOf7IoT3+MI3wY5tKAVsMBBu5McwjtRs qiAzmbbZFVhow0ZZVb+h7t/km748Bc3kuI2XMIUY6xISfx7t+lo9QHlSoaS8 X-Google-Smtp-Source: AGHT+IHPFebJHkxYPp6R3JituOJEY2EkPnLFwd9BEyYasUFMuJfVjnmI0ln7Zx0C+lEHmtD/8ZNRPw== X-Received: by 2002:a17:907:d2a:b0:a47:f286:d9f8 with SMTP id gn42-20020a1709070d2a00b00a47f286d9f8mr2420959ejc.43.1711359674452; Mon, 25 Mar 2024 02:41:14 -0700 (PDT) Original-Received: from localhost (netacc-gpn-204-42-119.pool.yettel.hu. [5.204.42.119]) by smtp.gmail.com with ESMTPSA id q5-20020a170906388500b00a473362062fsm2850001ejd.220.2024.03.25.02.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 02:41:13 -0700 (PDT) In-reply-to: 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:282062 Archived-At: Hi Alan, I agree, "if consteval" looks weird indeed. With your patch, "if consteval" indents correctly. I used cc-mode=20 with your patch for a day, haven't noticed any newly introduced=20 bugs. Thank you, and get better! G=C3=A9za Alan Mackenzie writes: > Hello, G=C3=A9za. > > Sorry it's taken a long time to respond. I've been unwell. > > On Tue, Feb 20, 2024 at 21:21:27 +0100, Herman wrote: > >> C++ has a new feature, "if consteval". So one can write code=20 >> like > >> if consteval { >> // do something >> } else { >> // do something else >> } > > Yes, indeed. Maybe I'm the only person to think so, but I think=20 > it's a > horrible distortion of C syntax. Anyway ... > >> The problem is that cc-mode doesn't recognize this construct,=20 >> lines >> are not indented correctly: the "// do something" and the "}=20 >> else {" >> receive an additional level of indentation. > > Would you please try out the patch below on your Emacs, then=20 > byte > compile CC Mode in its entirety (there are new macros) then load=20 > it into > a running Emacs (or restart Emacs). cc-mode is in=20 > .../lisp/progmodes. > > Then please let me know how well it fixes the bug. Thanks! > >> In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, cairo=20 >> version >> 1.18.0) of 2023-11-29 built on okoska >> Repository revision: 47837b3863deba274f16960f1ee9fde4acb9d5a1 >> Repository branch: my-modifications >> Windowing system distributor 'The X.Org Foundation', version=20 >> 11.0.12101008 >> System Description: Debian GNU/Linux trixie/sid > > [ .... ] > > > > diff -r 779141971296 cc-engine.el > --- a/cc-engine.el Sun Dec 31 10:45:58 2023 +0000 > +++ b/cc-engine.el Fri Mar 22 12:54:39 2024 +0000 > @@ -12365,13 +12365,21 @@ > (zerop (c-backward-token-2 1 t lim)) > t) > (or (looking-at c-block-stmt-1-key) > - (and (eq (char-after) ?\() > - (zerop (c-backward-token-2 1 t lim)) > - (if (looking-at c-block-stmt-hangon-key) > - (zerop (c-backward-token-2 1 t lim)) > - t) > - (or (looking-at c-block-stmt-2-key) > - (looking-at c-block-stmt-1-2-key)))) > + (or > + (and > + (eq (char-after) ?\() > + (zerop (c-backward-token-2 1 t lim)) > + (if (looking-at c-block-stmt-hangon-key) > + (zerop (c-backward-token-2 1 t lim)) > + t) > + (or (looking-at c-block-stmt-2-key) > + (looking-at c-block-stmt-1-2-key))) > + (and (looking-at c-paren-clause-key) > + (zerop (c-backward-token-2 1 t lim)) > + (if (looking-at c-negation-op-re) > + (zerop (c-backward-token-2 1 t lim)) > + t) > + (looking-at c-block-stmt-with-key)))) > (point)))) > > (defun c-after-special-operator-id (&optional lim) > diff -r 779141971296 cc-langs.el > --- a/cc-langs.el Sun Dec 31 10:45:58 2023 +0000 > +++ b/cc-langs.el Fri Mar 22 12:54:39 2024 +0000 > @@ -1583,6 +1583,12 @@ > (c-lang-defvar c-assignment-op-regexp > (c-lang-const c-assignment-op-regexp)) > > +(c-lang-defconst c-negation-op-re > + ;; Regexp matching the negation operator. > + t "!\\([^=3D]\\|$\\)") > + > +(c-lang-defvar c-negation-op-re (c-lang-const=20 > c-negation-op-re)) > + > (c-lang-defconst c-arithmetic-operators > "List of all arithmetic operators, including \"+=3D\", etc." > ;; Note: in the following, there are too many operators for=20 > AWK and IDL. > @@ -3149,6 +3155,30 @@ > (c-lang-const c-block-stmt-2-kwds))))) > (c-lang-defvar c-opt-block-stmt-key (c-lang-const=20 > c-opt-block-stmt-key)) > > +(c-lang-defconst c-paren-clause-kwds > + "Keywords which can stand in the place of paren sexps in=20 > conditionals. > +This applies only to conditionals in `c-block-stmt-with-kwds'." > + t nil > + c++ '("consteval")) > + > +(c-lang-defconst c-paren-clause-key > + ;; Regexp matching a keyword in `c-paren-clause-kwds'. > + t (c-make-keywords-re t > + (c-lang-const c-paren-clause-kwds))) > +(c-lang-defvar c-paren-clause-key (c-lang-const=20 > c-paren-clause-key)) > + > +(c-lang-defconst c-block-stmt-with-kwds > + "Statement keywords which can be followed by a keyword=20 > instead of a parens. > +Such a keyword is a member of `c-paren-clause-kwds." > + t nil > + c++ '("if")) > + > +(c-lang-defconst c-block-stmt-with-key > + ;; Regexp matching a keyword in `c-block-stmt-with-kwds'. > + t (c-make-keywords-re t > + (c-lang-const c-block-stmt-with-kwds))) > +(c-lang-defvar c-block-stmt-with-key (c-lang-const=20 > c-block-stmt-with-key)) > + > (c-lang-defconst c-simple-stmt-kwds > "Statement keywords followed by an expression or nothing." > t '("break" "continue" "goto" "return")