GNU bug report logs -
#7579
cc-mode c++ template-typed variable decl regression
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7579 in the body.
You can then email your comments to 7579 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#7579
; Package
emacs
.
(Tue, 07 Dec 2010 10:54: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
.
(Tue, 07 Dec 2010 10:54:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
/* In Emacs 23, adffdfa below is fontified as a variable. In Emacs HEAD,
it is not. */
void foo()
{
mumble x(5);
std::vector<int> adffdfa(1,2,3);
};
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#7579
; Package
emacs
.
(Tue, 07 Dec 2010 13:18:02 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 12/7/10 2:55 AM, Daniel Colascione wrote:
> /* In Emacs 23, adffdfa below is fontified as a variable. In Emacs HEAD,
> it is not. */
>
> void foo()
> {
> mumble x(5);
> std::vector<int> adffdfa(1,2,3);
> };
>
>
Never mind --- this is a manifestation of bug 7405.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
iEYEARECAAYFAkz+M/cACgkQ17c2LVA10Vsp7ACfYNwuW/aL4C1YOETbpX1gwwsz
GN8AoMZOP22xLEeTaB0btb5vD4YdQapI
=DP2/
-----END PGP SIGNATURE-----
Forcibly Merged 7406 7579.
Request was from
Stefan Monnier <monnier <at> iro.umontreal.ca>
to
control <at> debbugs.gnu.org
.
(Tue, 07 Dec 2010 17:28:02 GMT)
Full text and
rfc822 format available.
Disconnected #7579 from all other report(s).
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Tue, 07 Dec 2010 18:10:02 GMT)
Full text and
rfc822 format available.
Severity set to 'normal' from 'wishlist'
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Tue, 07 Dec 2010 18:10:02 GMT)
Full text and
rfc822 format available.
bug reassigned from package 'emacs' to 'emacs,cc-mode'.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Tue, 07 Dec 2010 18:10:03 GMT)
Full text and
rfc822 format available.
bug No longer marked as found in versions 24.0.50.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Tue, 07 Dec 2010 18:10:03 GMT)
Full text and
rfc822 format available.
Merged 7405 7579.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Tue, 07 Dec 2010 18:12:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org
:
bug#7579
; Package
emacs,cc-mode
.
(Tue, 14 Feb 2012 14:17:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 7579 <at> debbugs.gnu.org (full text, mbox):
Hi Alan,
Could you take a look at Bug#7579 too? Thanks:
Daniel Colascione <dan.colascione <at> gmail.com> wrote:
> /* In Emacs 23, adffdfa below is fontified as a variable. In Emacs HEAD,
> it is not. */
>
> void foo()
> {
> mumble x(5);
> std::vector<int> adffdfa(1,2,3);
> };
Information forwarded
to
bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org
:
bug#7579
; Package
emacs,cc-mode
.
(Tue, 14 Feb 2012 15:27:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 7579 <at> debbugs.gnu.org (full text, mbox):
Hi, Daniel.
On Tue, Feb 14, 2012 at 10:14:33PM +0800, Chong Yidong wrote:
> Hi Alan,
> Could you take a look at Bug#7579 too? Thanks:
> Daniel Colascione <dan.colascione <at> gmail.com> wrote:
> > /* In Emacs 23, adffdfa below is fontified as a variable. In Emacs HEAD,
> > it is not. */
> > void foo()
> > {
> > mumble x(5);
> > std::vector<int> adffdfa(1,2,3);
> > };
Are there any syntactic clues here that a variable rather than a function
is being declared? All I can see is that numeric literals take the place
of "parameters".
--
Alan Mackenzie (Nuremberg, Germany).
Information forwarded
to
bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org
:
bug#7579
; Package
emacs,cc-mode
.
(Tue, 14 Feb 2012 16:14:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 7579 <at> debbugs.gnu.org (full text, mbox):
Hello again,
On Tue, Feb 14, 2012 at 03:24:43PM +0000, Alan Mackenzie wrote:
> Hi, Daniel.
> On Tue, Feb 14, 2012 at 10:14:33PM +0800, Chong Yidong wrote:
> > Hi Alan,
> > Could you take a look at Bug#7579 too? Thanks:
> > Daniel Colascione <dan.colascione <at> gmail.com> wrote:
> > > /* In Emacs 23, adffdfa below is fontified as a variable. In Emacs HEAD,
> > > it is not. */
> > > void foo()
> > > {
> > > mumble x(5);
> > > std::vector<int> adffdfa(1,2,3);
> > > };
> Are there any syntactic clues here that a variable rather than a function
> is being declared? All I can see is that numeric literals take the place
> of "parameters".
Please ignore this request. Obviously, for a function, there must be
either nothing in the parentheses or [<type> <value>]*.
--
Alan Mackenzie (Nuremberg, Germany).
Information forwarded
to
bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org
:
bug#7579
; Package
emacs,cc-mode
.
(Tue, 14 Feb 2012 17:15:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 7579 <at> debbugs.gnu.org (full text, mbox):
Alan Mackenzie <acm <at> muc.de> writes:
> Please ignore this request. Obviously, for a function, there must be
> either nothing in the parentheses or [<type> <value>]*.
It can also be just a list of types.
Andreas.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Information forwarded
to
bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org
:
bug#7579
; Package
emacs,cc-mode
.
(Tue, 14 Feb 2012 17:19:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 7579 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi Alan,
On 2/14/12 8:11 AM, Alan Mackenzie wrote:
>>>> /* In Emacs 23, adffdfa below is fontified as a variable. In Emacs HEAD,
>>>> it is not. */
>
>>>> void foo()
>>>> {
>>>> mumble x(5);
>>>> std::vector<int> adffdfa(1,2,3);
>>>> };
>
>> Are there any syntactic clues here that a variable rather than a function
>> is being declared? All I can see is that numeric literals take the place
>> of "parameters".
>
> Please ignore this request. Obviously, for a function, there must be
> either nothing in the parentheses or [<type> <value>]*.
Or just types:
std::vector <int> blah(int);
typedef int foo;
std::vector <int> blah(foo);
Still, unless we're absolutely sure we're looking at a function
declaration, we should fontify a declaration as a variables
declaration. Function-scope function declarations are extremely
uncommon, and at least in my experience, almost always offset by
keywords like "extern". Even if something like int bar(); could be a
function, fontifying it as a variable would be the right thing to do
in function scope for C++.
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org
:
bug#7579
; Package
emacs,cc-mode
.
(Tue, 21 Feb 2012 14:09:01 GMT)
Full text and
rfc822 format available.
Message #38 received at 7579 <at> debbugs.gnu.org (full text, mbox):
Hello, Daniel.
On Tue, Feb 14, 2012 at 09:16:25AM -0800, Daniel Colascione wrote:
> Hi Alan,
> On 2/14/12 8:11 AM, Alan Mackenzie wrote:
> >>>> /* In Emacs 23, adffdfa below is fontified as a variable. In Emacs HEAD,
> >>>> it is not. */
> >>>> void foo()
> >>>> {
> >>>> mumble x(5);
> >>>> std::vector<int> adffdfa(1,2,3);
> >>>> };
> >> Are there any syntactic clues here that a variable rather than a function
> >> is being declared? All I can see is that numeric literals take the place
> >> of "parameters".
> > Please ignore this request. Obviously, for a function, there must be
> > either nothing in the parentheses or [<type> <value>]*.
> Or just types:
> std::vector <int> blah(int);
> typedef int foo;
> std::vector <int> blah(foo);
> Still, unless we're absolutely sure we're looking at a function
> declaration, we should fontify a declaration as a variables
> declaration. Function-scope function declarations are extremely
> uncommon, and at least in my experience, almost always offset by
> keywords like "extern". Even if something like int bar(); could be a
> function, fontifying it as a variable would be the right thing to do
> in function scope for C++.
OK, here's a patch to try out. As you requested, everything which might
look like a function which is directly within a function is treated as a
variable declaration, with one exception. That is a construct like
int (*foo) (bar);
, where foo continues to be a function.
If you can think of any other constructs which should still be functions,
please let me know. Please give the patch a stress test and let me know
how it works.
diff -r 9e9f3f646393 cc-fonts.el
--- a/cc-fonts.el Sun Feb 19 18:19:16 2012 +0000
+++ b/cc-fonts.el Tue Feb 21 13:58:37 2012 +0000
@@ -1009,6 +1009,7 @@
paren-depth
id-face got-init
c-last-identifier-range
+ maybe-function-type
(separator-prop (if types 'c-decl-type-start 'c-decl-id-start)))
;; The following `while' fontifies a single declarator id each time round.
@@ -1054,7 +1055,10 @@
(if (eq (char-after) ?\()
(progn
(setq paren-depth (1+ paren-depth))
- (forward-char))
+ (forward-char)
+ (c-forward-syntactic-ws)
+ (setq maybe-function-type
+ (eq (char-after) ?*)))
(goto-char (match-end 1)))
(c-forward-syntactic-ws))
@@ -1088,7 +1092,15 @@
"[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
(setq next-pos (match-beginning 0)
- id-face (if (eq (char-after next-pos) ?\()
+ id-face (if (and (eq (char-after next-pos) ?\()
+ (or maybe-function-type
+ (not (and (c-major-mode-is 'c++-mode)
+ (let (c-last-identifier-range
+ c-record-type-identifiers)
+ (save-excursion
+ (goto-char id-start)
+ (not (c-at-toplevel-p))))))))
+
'font-lock-function-name-face
'font-lock-variable-name-face)
got-init (and (match-beginning 1)
@@ -1141,6 +1153,7 @@
;; If a ',' is found we set pos to the next declarator and iterate.
(when (and (< (point) limit) (looking-at ","))
+ (setq maybe-function-type nil)
(c-put-char-property (point) 'c-type separator-prop)
(forward-char)
(c-forward-syntactic-ws limit)
--
Alan Mackenzie (Nuremberg, Germany).
bug closed, send any further explanations to
7579 <at> debbugs.gnu.org and Daniel Colascione <dan.colascione <at> gmail.com>
Request was from
Chong Yidong <cyd <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Wed, 11 Apr 2012 08:34: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
.
(Wed, 09 May 2012 11:24:03 GMT)
Full text and
rfc822 format available.
bug unarchived.
Request was from
Alan Mackenzie <acm <at> muc.de>
to
control <at> debbugs.gnu.org
.
(Wed, 03 Feb 2016 20:23:02 GMT)
Full text and
rfc822 format available.
Disconnected #7579 from all other report(s).
Request was from
Alan Mackenzie <acm <at> muc.de>
to
control <at> debbugs.gnu.org
.
(Wed, 03 Feb 2016 20:23:02 GMT)
Full text and
rfc822 format available.
Did not alter fixed versions and reopened.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 03 Feb 2016 20:23:02 GMT)
Full text and
rfc822 format available.
Reply sent
to
Alan Mackenzie <acm <at> muc.de>
:
You have taken responsibility.
(Thu, 04 Feb 2016 19:08:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Daniel Colascione <dan.colascione <at> gmail.com>
:
bug acknowledged by developer.
(Thu, 04 Feb 2016 19:08:02 GMT)
Full text and
rfc822 format available.
Message #53 received at 7579-done <at> debbugs.gnu.org (full text, mbox):
Hello, Daniel.
On Tue, Dec 07, 2010 at 02:55:00AM -0800, Daniel Colascione wrote:
> /* In Emacs 23, adffdfa below is fontified as a variable. In Emacs HEAD,
> it is not. */
> void foo()
> {
> mumble x(5);
> std::vector<int> adffdfa(1,2,3);
> };
The bug has been fixed in the emacs-25 branch.
--
Alan Mackenzie (Nuremberg, Germany).
Information forwarded
to
bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org
:
bug#7579
; Package
emacs,cc-mode
.
(Thu, 04 Feb 2016 19:18:02 GMT)
Full text and
rfc822 format available.
Message #56 received at 7579-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 02/04/2016 11:09 AM, Alan Mackenzie wrote:
> Hello, Daniel.
>
> On Tue, Dec 07, 2010 at 02:55:00AM -0800, Daniel Colascione wrote:
>> /* In Emacs 23, adffdfa below is fontified as a variable. In Emacs HEAD,
>> it is not. */
>
>> void foo()
>> {
>> mumble x(5);
>> std::vector<int> adffdfa(1,2,3);
>> };
>
> The bug has been fixed in the emacs-25 branch.
Thanks!
[signature.asc (application/pgp-signature, attachment)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 04 Mar 2016 12:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 9 years and 105 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.