llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Missing diagnostic for data member redeclaration with using-declaration involving virtual inheritance

Open miyuki opened this issue 4 years ago • 4 comments

The following code is not diagnosed by Clang trunk:

struct Base {
    int k;
};

struct A : virtual Base { };

struct B : virtual Base { };

struct T : A, B {
    using A::k, B::k;
};

Clang invocation:

$ clang -std=c++17 -fsyntax-only test.cc

I think the code is ill-formed according to C++17 [namespace.udecl]/10: "A using-declaration is a declaration and can therefore be used repeatedly where (and only where) multiple declarations are allowed."

GCC rejects this code:

<source>:10:20: error: redeclaration of 'using B::k'
   10 |     using A::k, B::k;
      |                    ^
<source>:10:14: note: previous declaration 'using A::k'
   10 |     using A::k, B::k;
      |              ^
Compiler returned: 1

miyuki avatar Mar 21 '22 17:03 miyuki

@llvm/issue-subscribers-clang-frontend

llvmbot avatar Mar 21 '22 17:03 llvmbot

@llvm/issue-subscribers-c-1

llvmbot avatar Mar 21 '22 17:03 llvmbot

Any progress on this?

vrukesh avatar Jan 22 '26 11:01 vrukesh

Nope - https://godbolt.org/z/8TKxs18dx.

xgupta avatar Jan 22 '26 11:01 xgupta