Issue 164885
Summary `clang-repl` fails to handle private member aliases in member function return types
Labels new issue
Assignees
Reporter 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`
```cpp
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.

```cpp
❯ 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.

```cpp
#include "asio-repro.hpp"

int main()
{ }
```

```bash
❯ clang++ main.cpp && ./a.out
```

## Versioning
* Linux x86_64
* LLVM 22 (head)

@vgvassilev for vis.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to