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#48837: Interaction between completion-moide and cc-mode new in 27.2 Date: Sun, 20 Jun 2021 18:43:33 +0000 Message-ID: References: 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="24672"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, 48837@debbugs.gnu.org To: "John C. Ruttenberg" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 20 20:44:10 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 1lv2QU-0006F4-A1 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Jun 2021 20:44:10 +0200 Original-Received: from localhost ([::1]:35712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lv2QS-0007tC-CY for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Jun 2021 14:44:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lv2QL-0007so-W0 for bug-gnu-emacs@gnu.org; Sun, 20 Jun 2021 14:44:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51580) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lv2QL-0001hR-Ok for bug-gnu-emacs@gnu.org; Sun, 20 Jun 2021 14:44:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lv2QL-0003kT-LO for bug-gnu-emacs@gnu.org; Sun, 20 Jun 2021 14:44:01 -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, 20 Jun 2021 18:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48837 X-GNU-PR-Package: emacs Original-Received: via spool by 48837-submit@debbugs.gnu.org id=B48837.162421462314378 (code B ref 48837); Sun, 20 Jun 2021 18:44:01 +0000 Original-Received: (at 48837) by debbugs.gnu.org; 20 Jun 2021 18:43:43 +0000 Original-Received: from localhost ([127.0.0.1]:34893 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lv2Q2-0003jq-Ou for submit@debbugs.gnu.org; Sun, 20 Jun 2021 14:43:43 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:50301 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1lv2Q0-0003jc-Ig for 48837@debbugs.gnu.org; Sun, 20 Jun 2021 14:43:41 -0400 Original-Received: (qmail 44031 invoked by uid 3782); 20 Jun 2021 18:43:33 -0000 Original-Received: from acm.muc.de (p2e5d544b.dip0.t-ipconnect.de [46.93.84.75]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 20 Jun 2021 20:43:33 +0200 Original-Received: (qmail 7823 invoked by uid 1000); 20 Jun 2021 18:43:33 -0000 Content-Disposition: inline In-Reply-To: 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:208802 Archived-At: Hello, John. Thanks for taking the trouble to report this bug, and thanks even more for cutting the test case down to an easy to work with minimum. On Fri, Jun 04, 2021 at 16:13:47 -0400, John C. Ruttenberg wrote: > This bug occurs in 27.2 but not in 26.3 > In a clean emacs "emacs -q --no-site-file": > 1. Enable dynamic completion "(dynamic-completion-mode)" > 2. Open a c++ source file > 3. Text should be: > foo() { > std::cerr < > int i = static_cast(z); > } > 4. Position the cursor directly after the "<" and type "< " (two > characters "<" " " > 5. I get this error message: "Scan error: containing expression ends > prematurely, 22, 22" The cause of this was that the "<" had wrongly been marked as an opening angle bracket. A backward `scan-sexps' Lisp instruction bumped into this barrier of an angle bracket and gave the error. The solution is to correct the reason for the spurious marking. That was that "static_cast" (along with three other newish ..._cast keywords) weren't being properly handled. This should be corrected in the supplied patch (which actually fixes a bit more). Would you please apply the following patch then byte-compile CC Mode in its entirety (as a Lisp macro has been changed). CC Mode is in ..../emacs/lisp/progmodes/cc-*.el Then please load the new CC Mode into your Emacs 27.2, test it on your real source code, and either confirm that the bug is fixed, or tell me where it is still going wrong. If you want any help with the patching or byte compiling, feel free to send me private email. Thanks! diff -r 92a4592886a1 cc-engine.el --- a/cc-engine.el Sun Apr 25 17:26:38 2021 +0000 +++ b/cc-engine.el Sun Jun 20 18:23:16 2021 +0000 @@ -6965,8 +6965,10 @@ (c-go-list-forward)) (when (equal (c-get-char-property (1- (point)) 'syntax-table) c->-as-paren-syntax) ; should always be true. - (c-unmark-<->-as-paren (1- (point)))) - (c-unmark-<->-as-paren pos)))) + (c-unmark-<->-as-paren (1- (point))) + (c-truncate-lit-pos-cache (1- (point)))) + (c-unmark-<->-as-paren pos) + (c-truncate-lit-pos-cache pos)))) (defun c-clear->-pair-props (&optional pos) ;; POS (default point) is at a > character. If it is marked with @@ -6982,8 +6984,10 @@ (c-go-up-list-backward)) (when (equal (c-get-char-property (point) 'syntax-table) c-<-as-paren-syntax) ; should always be true. - (c-unmark-<->-as-paren (point))) - (c-unmark-<->-as-paren pos)))) + (c-unmark-<->-as-paren (point)) + (c-truncate-lit-pos-cache (point))) + (c-unmark-<->-as-paren pos) + (c-truncate-lit-pos-cache pos)))) (defun c-clear-<>-pair-props (&optional pos) ;; POS (default point) is at a < or > character. If it has an @@ -7016,7 +7020,8 @@ (equal (c-get-char-property (1- (point)) 'syntax-table) c->-as-paren-syntax)) ; should always be true. (c-unmark-<->-as-paren (1- (point))) - (c-unmark-<->-as-paren pos)) + (c-unmark-<->-as-paren pos) + (c-truncate-lit-pos-cache pos)) t))) (defun c-clear->-pair-props-if-match-before (lim &optional pos) @@ -7037,6 +7042,7 @@ (equal (c-get-char-property (point) 'syntax-table) c-<-as-paren-syntax)) ; should always be true. (c-unmark-<->-as-paren (point)) + (c-truncate-lit-pos-cache (point)) (c-unmark-<->-as-paren pos)) t))) @@ -8078,13 +8084,14 @@ ;; bracket arglist. It's propagated through the return value ;; on successful completion. (c-record-found-types c-record-found-types) + (syntax-table-prop-on-< (c-get-char-property (point) 'syntax-table)) ;; List that collects the positions after the argument ;; separating ',' in the arglist. arg-start-pos) ;; If the '<' has paren open syntax then we've marked it as an angle ;; bracket arglist before, so skip to the end. (if (and (not c-parse-and-markup-<>-arglists) - (c-get-char-property (point) 'syntax-table)) + syntax-table-prop-on-<) (progn (forward-char) @@ -8167,8 +8174,20 @@ (c-put-c-type-property (1- (car arg-start-pos)) 'c-<>-arg-sep) (setq arg-start-pos (cdr arg-start-pos))) + (when (and (not syntax-table-prop-on-<) + (c-get-char-property (1- (point)) + 'syntax-table)) + ;; Clear the now spuriously matching < of its + ;; syntax-table property. This could happen on + ;; inserting "_cast" into "static <" with C-y. + (save-excursion + (and (c-go-list-backward) + (eq (char-after) ?<) + (c-truncate-lit-pos-cache (point)) + (c-unmark-<->-as-paren (point))))) (c-mark-<-as-paren start) - (c-mark->-as-paren (1- (point)))) + (c-mark->-as-paren (1- (point))) + (c-truncate-lit-pos-cache start)) (setq res t) nil)) ; Exit the loop. diff -r 92a4592886a1 cc-langs.el --- a/cc-langs.el Sun Apr 25 17:26:38 2021 +0000 +++ b/cc-langs.el Sun Jun 20 18:23:16 2021 +0000 @@ -2730,7 +2730,8 @@ `c-recognize-<>-arglists' for details. That language constant is assumed to be set if this isn't nil." t nil - c++ '("template") + c++ '("template" "const_cast" "dynamic_cast" "reinterpret_cast" + "static_cast") idl '("fixed" "string" "wstring")) (c-lang-defconst c-<>-sexp-kwds > In GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20) > of 2021-06-02 built on catb > Windowing system distributor 'AT&T Laboratories Cambridge', version > 11.0.3332 > System Description: Ubuntu 20.04.2 LTS [ .... ] -- Alan Mackenzie (Nuremberg, Germany).