Skip to content

Commit a013806

Browse files
committed
[Clang][Sema] Fix bug where operator-> typo corrects in the current instantiation
1 parent 119aecb commit a013806

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

clang/lib/Sema/SemaExprMember.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -995,8 +995,6 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
995995
// arrow operator was used with a dependent non-pointer object expression,
996996
// build a CXXDependentScopeMemberExpr.
997997
if (R.wasNotFoundInCurrentInstantiation() ||
998-
(IsArrow && !BaseExprType->isPointerType() &&
999-
BaseExprType->isDependentType()) ||
1000998
(R.getLookupName().getCXXOverloadedOperator() == OO_Equal &&
1001999
(SS.isSet() ? SS.getScopeRep()->isDependent()
10021000
: BaseExprType->isDependentType())))
@@ -1322,7 +1320,11 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R,
13221320
else if (const ObjCObjectPointerType *Ptr =
13231321
BaseType->getAs<ObjCObjectPointerType>())
13241322
BaseType = Ptr->getPointeeType();
1325-
else if (!BaseType->isDependentType()) {
1323+
else if (BaseType->isFunctionType())
1324+
goto fail;
1325+
else if (BaseType->isDependentType())
1326+
BaseType = S.Context.DependentTy;
1327+
else {
13261328
if (BaseType->isRecordType()) {
13271329
// Recover from arrow accesses to records, e.g.:
13281330
// struct MyRecord foo;
@@ -1337,8 +1339,6 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R,
13371339
<< FixItHint::CreateReplacement(OpLoc, ".");
13381340
}
13391341
IsArrow = false;
1340-
} else if (BaseType->isFunctionType()) {
1341-
goto fail;
13421342
} else {
13431343
S.Diag(MemberLoc, diag::err_typecheck_member_reference_arrow)
13441344
<< BaseType << BaseExpr.get()->getSourceRange();

clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,4 +551,11 @@ namespace N4 {
551551

552552
template void D<B>::instantiated(D); // expected-note {{in instantiation of}}
553553

554+
template<typename T>
555+
struct Typo {
556+
void not_instantiated(Typo a) {
557+
a->Not_instantiated;
558+
a->typo;
559+
}
560+
};
554561
} // namespace N4

0 commit comments

Comments
 (0)