Gábor Spaits 48521209aa
[Sema]Use tag name lookup for class names (#112166)
This PR would fix #16855 .

The correct lookup to use for class names is Tag name lookup,
because it does not take namespaces into account. The lookup before
does and because of this some valid programs are not accepted.

An example scenario of a valid program being declined is when you have a struct (let's call it `y`) inheriting from another struct with a name `x` but the struct `y` is in a namespace that is also called `x`:
```
struct x
{};

namespace
{
    namespace x
    {
        struct y : x
        {};
    }
}
```

This shall be accepted because: 
```
C++ [class.derived]p2 (wrt lookup in a base-specifier): The lookup for
  // the component name of the type-name or simple-template-id is type-only.
```
2024-10-15 10:19:17 +02:00

22 lines
422 B
C++

// RUN: %clang_cc1 %s -fsyntax-only -verify
// expected-no-diagnostics
// "During the lookup for a base class name, non-type names are ignored"
namespace PR5840 {
struct Base {};
int Base = 10;
struct Derived : Base {};
} // namespace PR5840
namespace issue_16855 {
struct x {};
namespace
{
namespace x
{
struct y : x
{};
} // namespace x
}
} // namespace issue_16855