[clang] [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)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 1 09:41:28 PDT 2024


================
@@ -1055,9 +1045,19 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
       }
     }
 
-    Diag(R.getNameLoc(), diag::err_no_member)
-      << MemberName << DC
-      << (BaseExpr ? BaseExpr->getSourceRange() : SourceRange());
+    if (SS.isNotEmpty() && !DC) {
+      Diag(R.getNameLoc(), diag::err_undeclared_use)
+          << MemberName << SS.getRange();
+    } else if (DC) {
+      Diag(R.getNameLoc(), diag::err_no_member)
+          << MemberName << DC
+          << (BaseExpr ? BaseExpr->getSourceRange() : SourceRange());
+    } else {
+      // FIXME: Is this needed?
----------------
erichkeane wrote:

Did you try just asserting here?  Also: I think I'd prefer us just merging this and the above branch, potentially with a ternary on `DC`.

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


More information about the cfe-commits mailing list