[clang] [clang-tools-extra] [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 (PR #84050)

Krystian Stasiowski via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 8 06:12:56 PDT 2024


sdkrystian wrote:

@erichkeane PR updated. 

When we encounter a class member access expression with a nested-name-specifier that is invalid, should we simply ignore it and instead use the type of the object expression as the lookup context? This is the current behavior, but it leads to lots of duplicate diagnostics. For example:
```cpp
struct A
{
    using I = int;
};

void f(A* x)
{
    x->I::z; // error: 'A::I' (aka 'int') is not a class, namespace, or enumeration
               // error: no member named 'z' in 'A'
}
```
IMO we should just return `ExprError` from `BuildMemberReferenceExpr` and thus not emit the second error.

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


More information about the cfe-commits mailing list