Skip to content

clang-repl fails to handle private member aliases in member function return types #164885

@jeaye

Description

@jeaye

Overview

In practice, I have seen this using clang::Interpreter to load Boost Asio (or standalone Asio). They both fail to load with compilation errors which don't occur using normal Clang. I have traced this down to a simplified reproduction case shown here:

asio-repro.hpp

struct scheduler
{ };

class io_context
{
  using impl_type = scheduler;

public:
  impl_type *foo();
};

/* The error doesn't occur if `impl_type` is a parameter type. Only for the return type. */
io_context::impl_type *io_context::foo()
{ return nullptr; }

clang-repl

If we start up clang-repl and include this file, we'll get a compilation error.

❯ clang-repl
clang-repl> #include "asio-repro.hpp"
In file included from <<< inputs >>>:1:
In file included from input_line_1:1:
./asio-repro.hpp:13:13: error: 'impl_type' is a private member of 'io_context'
   13 | io_context::impl_type *io_context::add_impl()
      |             ^
./asio-repro.hpp:7:9: note: implicitly declared private here
    7 |   using impl_type = scheduler;
      |         ^
error: Parsing failed.

Normal clang

However, if we create a simple main.cpp and compile it with clang, there's no problem.

#include "asio-repro.hpp"

int main()
{ }
❯ clang++ main.cpp && ./a.out

Versioning

  • Linux x86_64
  • LLVM 22 (head)

This is not a new issue. I have checked back to LLVM 20 and the issue is still present.

@vgvassilev for vis.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions