all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Daniel Colascione <dan.colascione@gmail.com>
Cc: 7917@debbugs.gnu.org
Subject: bug#7917: [PATCH] cc-mode: not all templates are types
Date: Fri, 1 Apr 2016 13:07:14 +0000	[thread overview]
Message-ID: <20160401130714.GA5228@acm.fritz.box> (raw)
In-Reply-To: <AANLkTi=KTbGo_gu04T9A38BOrCFUj488M_3WDN08YvZh@mail.gmail.com>

Hello, Daniel.

I've committed a fix for bug #7917 into the emacs-25 branch.  It's
basically your patch, but with one or two extra bits to cope with a
nasty little problem it caused in a Java Mode test file.

Would you try it out, please, and confirm that it has indeed fixed the
bug, or let me know what is still wrong.  Thanks!

-- 
Alan Mackenzie (Nuremberg, Germany).



On Tue, Jan 25, 2011 at 10:29:01PM -0800, Daniel Colascione wrote:
> None of the templates here should be fontified as types.

> template<typename T>
> void foo(T t)
> {}

> template<>
> void foo<int>(int x)
> {}

> void bar()
> {
>     foo<int>(5);
> }

> === modified file 'lisp/progmodes/cc-engine.el'
> --- lisp/progmodes/cc-engine.el	2010-12-09 07:52:58 +0000
> +++ lisp/progmodes/cc-engine.el	2011-01-26 05:06:59 +0000
> @@ -5850,11 +5850,12 @@
>  	       (when (let ((c-record-type-identifiers t)
>  			   (c-record-found-types t))
>  		       (c-forward-<>-arglist nil))
> -
> -		 (c-add-type start (1+ pos))
> +		 
>  		 (c-forward-syntactic-ws)
> -		 (setq pos (point)
> -		       c-last-identifier-range nil)
> +		 (unless (eq (char-after) ?\()
> +		   (setq c-last-identifier-range nil)
> +		   (c-add-type start (1+ pos)))
> +		 (setq pos (point))
 
>  		 (if (and c-opt-identifier-concat-key
>  			  (looking-at c-opt-identifier-concat-key))
> @@ -5868,7 +5869,8 @@
>  		       (c-forward-syntactic-ws)
>  		       t)
 
> -		   (when (and c-record-type-identifiers id-start)
> +		   (when (and c-record-type-identifiers id-start
> +			      (not (eq (char-after) ?\()))
>  		     (c-record-type-id (cons id-start id-end)))
>  		   (setq res 'template)
>  		   nil)))
> @@ -6054,9 +6056,17 @@
>  			   ;; It's an identifier that might be a type.
>  			   'maybe))))
>  	    ((eq name-res 'template)
> -	     ;; A template is a type.
> +	     ;; A template is sometimes a type.
>  	     (goto-char id-end)
> -	     (setq res t))
> +	     (setq res
> +		   (if (eq (char-after) ?\()
> +		       (if (c-check-type id-start id-end)
> +			   ;; It's an identifier that has been used as
> +			   ;; a type somewhere else.
> +			   'found
> +			 ;; It's an identifier that might be a type.
> +			 'maybe)
> +		     t)))
>  	    (t
>  	     ;; Otherwise it's an operator identifier, which is not a type.
>  	     (goto-char start)

> === modified file 'lisp/progmodes/cc-fonts.el'
> --- lisp/progmodes/cc-fonts.el	2011-01-25 11:20:25 +0000
> +++ lisp/progmodes/cc-fonts.el	2011-01-25 12:58:26 +0000
> @@ -835,11 +835,12 @@
>  		    (when (and c-opt-identifier-concat-key
>  			       (not (get-text-property id-start 'face)))
>  		      (c-forward-syntactic-ws)
> -		      (if (looking-at c-opt-identifier-concat-key)
> -			  (c-put-font-lock-face id-start id-end
> -						c-reference-face-name)
> -			(c-put-font-lock-face id-start id-end
> -					      'font-lock-type-face)))))
> +		      (cond ((looking-at c-opt-identifier-concat-key)
> +			     (c-put-font-lock-face id-start id-end
> +						c-reference-face-name))
> +			    ((eq (char-after) ?\())
> +			    (t (c-put-font-lock-face id-start id-end
> +					      'font-lock-type-face))))))
 
>  		(goto-char pos)))
>  	  (goto-char pos)))))






  parent reply	other threads:[~2016-04-01 13:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-26  6:29 bug#7917: [PATCH] cc-mode: not all templates are types Daniel Colascione
2016-02-26  6:22 ` Lars Ingebrigtsen
2016-02-26  6:30   ` Daniel Colascione
2016-02-26  7:10     ` Lars Ingebrigtsen
2016-02-27  4:03       ` Lars Ingebrigtsen
2016-02-28 21:32         ` Alan Mackenzie
2016-02-29  2:51           ` Lars Ingebrigtsen
2016-02-29 22:14             ` Alan Mackenzie
2016-04-01 13:07 ` Alan Mackenzie [this message]
2017-06-29  1:02   ` npostavs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160401130714.GA5228@acm.fritz.box \
    --to=acm@muc.de \
    --cc=7917@debbugs.gnu.org \
    --cc=dan.colascione@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.