Subject: Re: bug#59216: CC Mode 5.35.2 (C++//l); Incorrect fontification of "static key_map *key_map"

From: Po Lu <[email-masked]>
Date: Sun, 13 Nov 2022 08:29:41 +0800

Alan Mackenzie <[email-masked]> writes:

> Hello, Po.
>
> On Sat, Nov 12, 2022 at 21:09:31 +0800, Po Lu via CC-Mode-help wrote:
>> Package: cc-mode
>
>> Go to src/haiku_support.cc.  Around line 171, there will be:
>
>> /* The keymap, or NULL if it has not been initialized.  */
>> static key_map *key_map;
>
>> the variable name will be fontified as a type!
>
> Er, that's the variable name the same as the type name.  Is that valid
> C++?  I always thought that types and variables shared a name space.
>
> What am I missing, here?

Here's what the internet says:

  According to the C++ standard, declaring a variable with the same name
  as a type is correct code in general, but invalid code within a class
  definition. The class case is specific, because names declared in a
  class definition are visible within the whole class definition, before
  and after the point of declaration of that name. In other scopes
  (global, namespace, function, ...) declared names are visible only
  after the point of declaration.