GNU bug report logs - #7917
[PATCH] cc-mode: not all templates are types

Previous Next

Packages: emacs, cc-mode;

Reported by: Daniel Colascione <dan.colascione <at> gmail.com>

Date: Wed, 26 Jan 2011 06:22:02 UTC

Severity: minor

Tags: confirmed, fixed, patch

Found in version 24.5

Fixed in version 25.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7917 in the body.
You can then email your comments to 7917 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7917; Package emacs. (Wed, 26 Jan 2011 06:22:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Daniel Colascione <dan.colascione <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 26 Jan 2011 06:22:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Daniel Colascione <dan.colascione <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] cc-mode: not all templates are types
Date: Tue, 25 Jan 2011 22:29:01 -0800
[Message part 1 (text/plain, inline)]
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);
}
[templatefunc.patch (text/plain, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#7917; Package emacs,cc-mode. (Fri, 26 Feb 2016 06:23:02 GMT) Full text and rfc822 format available.

Message #8 received at 7917 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Daniel Colascione <dan.colascione <at> gmail.com>
Cc: 7917 <at> debbugs.gnu.org
Subject: Re: bug#7917: [PATCH] cc-mode: not all templates are types
Date: Fri, 26 Feb 2016 16:52:27 +1030
Daniel Colascione <dan.colascione <at> gmail.com> writes:

> 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);
> }

On the Emacs trunk, I can't see anything immediately wrong about the
fontification of the templates -- they're all fontified with the keyword
face.

So has this been fixed in the meantime (just five years)?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#7917; Package emacs,cc-mode. (Fri, 26 Feb 2016 06:31:02 GMT) Full text and rfc822 format available.

Message #11 received at 7917 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Colascione <dancol <at> dancol.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>,
 Daniel Colascione <dan.colascione <at> gmail.com>
Cc: 7917 <at> debbugs.gnu.org
Subject: Re: bug#7917: [PATCH] cc-mode: not all templates are types
Date: Thu, 25 Feb 2016 22:30:06 -0800
[Message part 1 (text/plain, inline)]
On 02/25/2016 10:22 PM, Lars Ingebrigtsen wrote:
> Daniel Colascione <dan.colascione <at> gmail.com> writes:
> 
>> 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);
>> }
> 
> On the Emacs trunk, I can't see anything immediately wrong about the
> fontification of the templates -- they're all fontified with the keyword
> face.
> 
> So has this been fixed in the meantime (just five years)?
> 

For me --- empty scratch buffer, c++-mode, emacs -Q, pasting in
this example, the name of the second function is fontified as a type,
not a function name. In the third function, in the call to foo<int>, foo
is also fontified as a type, although it shouldn't be fontified as
anything at all.

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#7917; Package emacs,cc-mode. (Fri, 26 Feb 2016 07:11:02 GMT) Full text and rfc822 format available.

Message #14 received at 7917 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: Daniel Colascione <dan.colascione <at> gmail.com>, 7917 <at> debbugs.gnu.org
Subject: Re: bug#7917: [PATCH] cc-mode: not all templates are types
Date: Fri, 26 Feb 2016 17:40:06 +1030
Daniel Colascione <dancol <at> dancol.org> writes:

> For me --- empty scratch buffer, c++-mode, emacs -Q, pasting in
> this example, the name of the second function is fontified as a type,
> not a function name. In the third function, in the call to foo<int>, foo
> is also fontified as a type, although it shouldn't be fontified as
> anything at all.

Oh, yeah, that's true.  

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) confirmed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 26 Feb 2016 07:11:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#7917; Package emacs,cc-mode. (Sat, 27 Feb 2016 04:05:02 GMT) Full text and rfc822 format available.

Message #19 received at 7917 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: bug-cc-mode <at> gnu.org, Daniel Colascione <dan.colascione <at> gmail.com>,
 7917 <at> debbugs.gnu.org
Subject: Re: bug#7917: [PATCH] cc-mode: not all templates are types
Date: Sat, 27 Feb 2016 14:33:36 +1030
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Daniel Colascione <dancol <at> dancol.org> writes:
>
>> For me --- empty scratch buffer, c++-mode, emacs -Q, pasting in
>> this example, the name of the second function is fontified as a type,
>> not a function name. In the third function, in the call to foo<int>, foo
>> is also fontified as a type, although it shouldn't be fontified as
>> anything at all.
>
> Oh, yeah, that's true.  

And your patch fixes the issue.  Does anybody have any objections to
applying the patch?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#7917; Package emacs,cc-mode. (Sun, 28 Feb 2016 21:30:02 GMT) Full text and rfc822 format available.

Message #22 received at 7917 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: bug-cc-mode <at> gnu.org, Daniel Colascione <dancol <at> dancol.org>,
 Daniel Colascione <dan.colascione <at> gmail.com>, 7917 <at> debbugs.gnu.org
Subject: Re: bug#7917: [PATCH] cc-mode: not all templates are types
Date: Sun, 28 Feb 2016 21:32:07 +0000
Hello, Lars.

On Sat, Feb 27, 2016 at 02:33:36PM +1030, Lars Ingebrigtsen wrote:
> Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> > Daniel Colascione <dancol <at> dancol.org> writes:

> >> For me --- empty scratch buffer, c++-mode, emacs -Q, pasting in
> >> this example, the name of the second function is fontified as a type,
> >> not a function name. In the third function, in the call to foo<int>, foo
> >> is also fontified as a type, although it shouldn't be fontified as
> >> anything at all.

> > Oh, yeah, that's true.  

> And your patch fixes the issue.  Does anybody have any objections to
> applying the patch?

The patch breaks the fontification of certain Java constructs, in
particular, ones looking like this:

    Map<String, Driver> allDrivers = new Map<String, Driver>();
                                         ^^^

With the patch in place, the indicated "Map" doesn't get fontified in
font-lock-type-face as it should.

Before applying any patches like this to CC Mode, could you please run
them through the CC Mode test suite first (or ask Daniel (the OP) or me
to do it).  Thanks!

> -- 
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#7917; Package emacs,cc-mode. (Mon, 29 Feb 2016 02:53:01 GMT) Full text and rfc822 format available.

Message #25 received at 7917 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: bug-cc-mode <at> gnu.org, Daniel Colascione <dancol <at> dancol.org>,
 Daniel Colascione <dan.colascione <at> gmail.com>, 7917 <at> debbugs.gnu.org
Subject: Re: bug#7917: [PATCH] cc-mode: not all templates are types
Date: Mon, 29 Feb 2016 13:51:29 +1100
Alan Mackenzie <acm <at> muc.de> writes:

> Before applying any patches like this to CC Mode, could you please run
> them through the CC Mode test suite first (or ask Daniel (the OP) or me
> to do it).  Thanks!

Is the CC Mode test suite included in the Emacs test/ directory
somewhere?  I looked around and didn't really find anything...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#7917; Package emacs,cc-mode. (Mon, 29 Feb 2016 22:12:01 GMT) Full text and rfc822 format available.

Message #28 received at 7917 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: bug-cc-mode <at> gnu.org, Daniel Colascione <dancol <at> dancol.org>,
 Daniel Colascione <dan.colascione <at> gmail.com>, 7917 <at> debbugs.gnu.org
Subject: Re: bug#7917: [PATCH] cc-mode: not all templates are types
Date: Mon, 29 Feb 2016 22:14:17 +0000
Hello, Lars.

On Mon, Feb 29, 2016 at 01:51:29PM +1100, Lars Ingebrigtsen wrote:
> Alan Mackenzie <acm <at> muc.de> writes:

> > Before applying any patches like this to CC Mode, could you please run
> > them through the CC Mode test suite first (or ask Daniel (the OP) or me
> > to do it).  Thanks!

> Is the CC Mode test suite included in the Emacs test/ directory
> somewhere?  I looked around and didn't really find anything...

No, it's only in CC Mode (the project) itself.  It's build up from
around 400 mostly small source files, each of which tests either
indentation, fontification, or both, together with an elisp file which
drives everything.

The (Mercurial) repository of CC Mode can be found via
<http://cc-mode <at> sourceforge.net/hgaccess.php>.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#7917; Package emacs,cc-mode. (Fri, 01 Apr 2016 13:05:01 GMT) Full text and rfc822 format available.

Message #31 received at 7917 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Daniel Colascione <dan.colascione <at> gmail.com>
Cc: 7917 <at> debbugs.gnu.org
Subject: Re: bug#7917: [PATCH] cc-mode: not all templates are types
Date: Fri, 1 Apr 2016 13:07:14 +0000
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)))))





Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#7917; Package emacs,cc-mode. (Thu, 29 Jun 2017 01:01:02 GMT) Full text and rfc822 format available.

Message #34 received at 7917 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Alan Mackenzie <acm <at> muc.de>
Cc: Daniel Colascione <dan.colascione <at> gmail.com>, 7917 <at> debbugs.gnu.org
Subject: Re: bug#7917: [PATCH] cc-mode: not all templates are types
Date: Wed, 28 Jun 2017 21:02:15 -0400
found 7917 24.5
severity 7917 minor
tags 7917 fixed
close 7917 25.1
quit

Alan Mackenzie <acm <at> muc.de> writes:

> 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!

I can see the bug in 24.5, but not in 25.1




bug Marked as found in versions 24.5. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 29 Jun 2017 01:01:02 GMT) Full text and rfc822 format available.

Severity set to 'minor' from 'normal' Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 29 Jun 2017 01:01:02 GMT) Full text and rfc822 format available.

Added tag(s) fixed. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 29 Jun 2017 01:01:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 25.1, send any further explanations to 7917 <at> debbugs.gnu.org and Daniel Colascione <dan.colascione <at> gmail.com> Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 29 Jun 2017 01:01:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 27 Jul 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 21 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.