Skip to content

Funny error message for invalid code. #53448

Closed as not planned
Closed as not planned
@CarloWood

Description

@CarloWood

Probably not worth fixing, but well.

namespace vulkan {
}

namespace xcb {
  
struct ModifierMask {
  static constexpr int Shift = 1;
};

} // namespace xcb

void test()
{
  using S = vulkan::ModifierMask::Shift;
}

Gives (with clang HEAD 14.0.0, as well as version 13).

prog.cc:14:13: error: no member named 'ModifierMask' in namespace 'vulkan';
did you mean 'xcb::ModifierMask'?
  using S = vulkan::ModifierMask::Shift;
            ^~~~~~~~~~~~~~~~~~~~
            xcb::ModifierMask
prog.cc:6:8: note: 'xcb::ModifierMask' declared here
struct ModifierMask {
       ^
prog.cc:14:35: error: no type named 'Shift' in 'xcb::ModifierMask'
  using S = vulkan::ModifierMask::Shift;
                    ~~~~~~~~~~~~~~^
2 errors generated.

gcc HEAD reports:

prog.cc: In function 'void test()':
prog.cc:14:21: error: 'ModifierMask' in namespace 'vulkan' does not name a type
   14 |   using S = vulkan::ModifierMask::Shift;
      |                     ^~~~~~~~~~~~

and leaves it at that.

The "bug" is that clang says that there isn't a type 'Shift' in 'xcb::ModifierMask' while there is no 'xcb::ModifierMask' insight imho. The actual problem was me forgetting to include the header that defines 'vulkan::ModifierMask::Shift'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerinvalidResolved as invalid, i.e. not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions