From 489561d46381d41a068beed1a2e18e00f0660248 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Thu, 14 Oct 2021 21:49:22 +0200 Subject: [PATCH] [clang] fix typo correction not looking for candidates in base classes. RecordMemberExprValidator was not looking through ElaboratedType nodes when looking for candidates which occur in base classes. Signed-off-by: Matheus Izvekov Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D111830 --- clang/lib/Sema/SemaExprMember.cpp | 5 ++--- clang/test/CXX/drs/dr1xx.cpp | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp index 2a3b696..83006f9 100644 --- a/clang/lib/Sema/SemaExprMember.cpp +++ b/clang/lib/Sema/SemaExprMember.cpp @@ -611,11 +611,10 @@ public: if (Record->containsDecl(ND)) return true; - if (const CXXRecordDecl *RD = dyn_cast(Record)) { + if (const auto *RD = dyn_cast(Record)) { // Accept candidates that occur in any of the current class' base classes. for (const auto &BS : RD->bases()) { - if (const RecordType *BSTy = - dyn_cast_or_null(BS.getType().getTypePtrOrNull())) { + if (const auto *BSTy = BS.getType()->getAs()) { if (BSTy->getDecl()->containsDecl(ND)) return true; } diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp index 4efa2e2..51abb36 100644 --- a/clang/test/CXX/drs/dr1xx.cpp +++ b/clang/test/CXX/drs/dr1xx.cpp @@ -477,7 +477,7 @@ namespace dr140 { // dr140: yes namespace dr141 { // dr141: yes template void f(); - template struct S { int n; }; + template struct S { int n; }; // expected-note {{'::dr141::S::n' declared here}} struct A : S { template void f(); template struct S {}; @@ -485,7 +485,7 @@ namespace dr141 { // dr141: yes struct B : S {} b; void g() { a.f(); - (void)a.S::n; // expected-error {{no member named 'n'}} + (void)a.S::n; // expected-error {{no member named 'n' in 'dr141::A::S'; did you mean '::dr141::S::n'?}} #if __cplusplus < 201103L // expected-error@-2 {{ambiguous}} // expected-note@-11 {{lookup from the current scope}} -- 2.7.4