[clang] [clang-tools-extra] Reapply "[Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent base classes (#84050)" (PR #90152)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Mon May 13 05:13:58 PDT 2024


ilya-biryukov wrote:

🤯  amazingly, this only happens when the identifier being called is a lowercase version of the class name:
https://gcc.godbolt.org/z/8aoaoPKnT:

```cpp
template <class T>
class Clone {
   public:
    Clone(const Clone<T>&);

    T* operator->() const;
    T* ptr_;
};

template <class T>
struct Foo {
    Foo(const Foo<T>&);
    T* operator->() const;
    T* ptr_;
};

// Assume T* T::clone()
template <class T>
inline Clone<T>::Clone(const Clone<T>& t) {
    t->foo(); // ok 
    t->clone(); // error
    t->bar(); // ok
}

// Assume T* T::clone()
template <class T>
inline Foo<T>::Foo(const Foo<T>& t) {
    t->foo(); // error
    t->clone(); // ok
    t->bar(); // ok
}
```


I am looking forward to learning what is special about the matching names.

https://github.com/llvm/llvm-project/pull/90152


More information about the cfe-commits mailing list