unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#7917: [PATCH] cc-mode: not all templates are types
@ 2011-01-26  6:29 Daniel Colascione
  2016-02-26  6:22 ` Lars Ingebrigtsen
  2016-04-01 13:07 ` Alan Mackenzie
  0 siblings, 2 replies; 10+ messages in thread
From: Daniel Colascione @ 2011-01-26  6:29 UTC (permalink / raw)
  To: 7917

[-- Attachment #1: Type: text/plain, Size: 165 bytes --]

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

[-- Attachment #2: templatefunc.patch --]
[-- Type: text/plain, Size: 2413 bytes --]

=== 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)))))


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-06-29  1:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2017-06-29  1:02   ` npostavs

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).