Skip to content

Commit 489561d

Browse files
committed
[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 <[email protected]> Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D111830
1 parent 1830ec9 commit 489561d

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

clang/lib/Sema/SemaExprMember.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,11 +611,10 @@ class RecordMemberExprValidatorCCC final : public CorrectionCandidateCallback {
611611
if (Record->containsDecl(ND))
612612
return true;
613613

614-
if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Record)) {
614+
if (const auto *RD = dyn_cast<CXXRecordDecl>(Record)) {
615615
// Accept candidates that occur in any of the current class' base classes.
616616
for (const auto &BS : RD->bases()) {
617-
if (const RecordType *BSTy =
618-
dyn_cast_or_null<RecordType>(BS.getType().getTypePtrOrNull())) {
617+
if (const auto *BSTy = BS.getType()->getAs<RecordType>()) {
619618
if (BSTy->getDecl()->containsDecl(ND))
620619
return true;
621620
}

clang/test/CXX/drs/dr1xx.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,15 @@ namespace dr140 { // dr140: yes
477477

478478
namespace dr141 { // dr141: yes
479479
template<typename T> void f();
480-
template<typename T> struct S { int n; };
480+
template<typename T> struct S { int n; }; // expected-note {{'::dr141::S<int>::n' declared here}}
481481
struct A : S<int> {
482482
template<typename T> void f();
483483
template<typename T> struct S {};
484484
} a;
485485
struct B : S<int> {} b;
486486
void g() {
487487
a.f<int>();
488-
(void)a.S<int>::n; // expected-error {{no member named 'n'}}
488+
(void)a.S<int>::n; // expected-error {{no member named 'n' in 'dr141::A::S<int>'; did you mean '::dr141::S<int>::n'?}}
489489
#if __cplusplus < 201103L
490490
// expected-error@-2 {{ambiguous}}
491491
// expected-note@-11 {{lookup from the current scope}}

0 commit comments

Comments
 (0)