Skip to content

Lookup for a dependent nested type as a base-specifier should be type-only #162813

@ckwastra

Description

@ckwastra

Test code (CE):

struct A {
  int B;
  struct B {};
};

struct S1 : A::B {}; // OK

// - EDG/MSVC: OK
// - GCC (<= 12.5): OK
// - GCC (>= 13.1): error: 'typename A::B' names 'int A::B', which is
//                         not a type
// - Clang: error: typename specifier refers to non-type member 'B' in
//                 'A'
template <class T> struct S2 : T::B {};
template class S2<A>;

According to [class.derived.general]/2 (from N4950, the C++23 final draft):

[...] The lookup for the component name of the type-name or simple-template-id is type-only ([basic.lookup]). [...]

Therefore, the lookup for B in T::B should be type-only (ignoring non-type names), since T::B appears within a class-or-decltype (which can be produced by a base-specifier or a mem-initializer-id).

Related: Bug 122192.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions