Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clang][Sema] Fix bug where operator-> typo corrects in the current instantiation #91972

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions clang/lib/Sema/SemaExprMember.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,8 +995,6 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
// arrow operator was used with a dependent non-pointer object expression,
// build a CXXDependentScopeMemberExpr.
if (R.wasNotFoundInCurrentInstantiation() ||
(IsArrow && !BaseExprType->isPointerType() &&
BaseExprType->isDependentType()) ||
(R.getLookupName().getCXXOverloadedOperator() == OO_Equal &&
(SS.isSet() ? SS.getScopeRep()->isDependent()
: BaseExprType->isDependentType())))
Expand Down Expand Up @@ -1322,7 +1320,11 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R,
else if (const ObjCObjectPointerType *Ptr =
BaseType->getAs<ObjCObjectPointerType>())
BaseType = Ptr->getPointeeType();
else if (!BaseType->isDependentType()) {
else if (BaseType->isFunctionType())
goto fail;
else if (BaseType->isDependentType())
BaseType = S.Context.DependentTy;
else {
if (BaseType->isRecordType()) {
// Recover from arrow accesses to records, e.g.:
// struct MyRecord foo;
Expand All @@ -1337,8 +1339,6 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R,
<< FixItHint::CreateReplacement(OpLoc, ".");
}
IsArrow = false;
} else if (BaseType->isFunctionType()) {
goto fail;
} else {
S.Diag(MemberLoc, diag::err_typecheck_member_reference_arrow)
<< BaseType << BaseExpr.get()->getSourceRange();
Expand Down
7 changes: 7 additions & 0 deletions clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,4 +551,11 @@ namespace N4 {

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

template<typename T>
struct Typo {
void not_instantiated(Typo a) {
a->Not_instantiated;
a->typo;
}
};
} // namespace N4
Loading