bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Alan Mackenzie
Subject: bug#7917: [PATCH] cc-mode: not all templates are types
Date: Fri, 1 Apr 2016 13:07:14 +0000
User-agent: Mutt/1.5.24 (2015-08-30)

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]