GNU bug report logs - #15415
24.3.50; c++-mode fontification for constructors is inconsistent

Previous Next

Packages: cc-mode, emacs;

Reported by: Ivan Andrus <darthandrus <at> gmail.com>

Date: Thu, 19 Sep 2013 02:46:01 UTC

Severity: normal

Found in version 24.3.50

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

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ivan Andrus <darthandrus <at> gmail.com>
To: 15415 <at> debbugs.gnu.org
Subject: bug#15415: 24.3.50; c++-mode fontification for constructors is inconsistent
Date: Sun, 29 Sep 2013 21:31:13 -0600
Ivan Andrus <darthandrus <at> gmail.com> writes:

> Font locking of C++ constructors is somewhat inconsistent.  This is no
> doubt complicated by the fact that unlike other function declarations
> they "don't have a return type".
>
> When a single argument is not used but named, the constructor is not
> fontified (normally it's fontified with `font-lock-function-name-face').
> If the keyword explicit is used, then the argument type is fontified as
> a variable, and the constructor name is fontified as a type.  Perhaps
> interestingly, naming the parameter or adding another parameter causes
> fontification to work correctly (with or without explicit).
>
> I have included a sample file below with comments on what I see in `emacs -q`
>
>
> class Bob
> {
>     // string is `font-lock-type-face', Bob is `font-lock-function-name-face'
>     Bob( string bob );
>     // string and Bob are not fontified (though I sometimes see string fontified as a type)
>     Bob( string );
>     // string is `font-lock-variable-name-face', Bob is `font-lock-type-face'
>     explicit Bob( string );
>     // string is `font-lock-type-face', Bob is `font-lock-function-name-face'
>     explicit Bob( string, string );
> };

In fact, it's not just constructors that have this problem.  For example
the following function declaration:

string lookup( size_t ) const;

Removing const, or adding a name to the size_t parameter causes
fontification to work correctly.

-Ivan




This bug report was last modified 11 years and 221 days ago.

Previous Next


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