@@ -995,8 +995,6 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
995
995
// arrow operator was used with a dependent non-pointer object expression,
996
996
// build a CXXDependentScopeMemberExpr.
997
997
if (R.wasNotFoundInCurrentInstantiation () ||
998
- (IsArrow && !BaseExprType->isPointerType () &&
999
- BaseExprType->isDependentType ()) ||
1000
998
(R.getLookupName ().getCXXOverloadedOperator () == OO_Equal &&
1001
999
(SS.isSet () ? SS.getScopeRep ()->isDependent ()
1002
1000
: BaseExprType->isDependentType ())))
@@ -1322,28 +1320,28 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R,
1322
1320
else if (const ObjCObjectPointerType *Ptr =
1323
1321
BaseType->getAs <ObjCObjectPointerType>())
1324
1322
BaseType = Ptr->getPointeeType ();
1325
- else if (!BaseType->isDependentType ()) {
1326
- if (BaseType->isRecordType ()) {
1327
- // Recover from arrow accesses to records, e.g.:
1328
- // struct MyRecord foo;
1329
- // foo->bar
1330
- // This is actually well-formed in C++ if MyRecord has an
1331
- // overloaded operator->, but that should have been dealt with
1332
- // by now--or a diagnostic message already issued if a problem
1333
- // was encountered while looking for the overloaded operator->.
1334
- if (!S.getLangOpts ().CPlusPlus ) {
1335
- S.Diag (OpLoc, diag::err_typecheck_member_reference_suggestion)
1336
- << BaseType << int (IsArrow) << BaseExpr.get ()->getSourceRange ()
1337
- << FixItHint::CreateReplacement (OpLoc, " ." );
1338
- }
1339
- IsArrow = false ;
1340
- } else if (BaseType->isFunctionType ()) {
1341
- goto fail;
1342
- } else {
1343
- S.Diag (MemberLoc, diag::err_typecheck_member_reference_arrow)
1344
- << BaseType << BaseExpr.get ()->getSourceRange ();
1345
- return ExprError ();
1323
+ else if (BaseType->isFunctionType ())
1324
+ goto fail;
1325
+ else if (BaseType->isDependentType ())
1326
+ BaseType = S.Context .DependentTy ;
1327
+ else if (BaseType->isRecordType ()) {
1328
+ // Recover from arrow accesses to records, e.g.:
1329
+ // struct MyRecord foo;
1330
+ // foo->bar
1331
+ // This is actually well-formed in C++ if MyRecord has an
1332
+ // overloaded operator->, but that should have been dealt with
1333
+ // by now--or a diagnostic message already issued if a problem
1334
+ // was encountered while looking for the overloaded operator->.
1335
+ if (!S.getLangOpts ().CPlusPlus ) {
1336
+ S.Diag (OpLoc, diag::err_typecheck_member_reference_suggestion)
1337
+ << BaseType << int (IsArrow) << BaseExpr.get ()->getSourceRange ()
1338
+ << FixItHint::CreateReplacement (OpLoc, " ." );
1346
1339
}
1340
+ IsArrow = false ;
1341
+ } else {
1342
+ S.Diag (MemberLoc, diag::err_typecheck_member_reference_arrow)
1343
+ << BaseType << BaseExpr.get ()->getSourceRange ();
1344
+ return ExprError ();
1347
1345
}
1348
1346
}
1349
1347
@@ -1363,7 +1361,7 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R,
1363
1361
}
1364
1362
1365
1363
// Handle field access to simple records.
1366
- if (BaseType->getAsRecordDecl () || BaseType-> isDependentType () ) {
1364
+ if (BaseType->getAsRecordDecl ()) {
1367
1365
TypoExpr *TE = nullptr ;
1368
1366
if (LookupMemberExprInRecord (S, R, BaseExpr.get (), BaseType, OpLoc, IsArrow,
1369
1367
SS, HasTemplateArgs, TemplateKWLoc, TE))
@@ -1374,6 +1372,9 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R,
1374
1372
// failed, the lookup result will have been cleared--that combined with the
1375
1373
// valid-but-null ExprResult will trigger the appropriate diagnostics.
1376
1374
return ExprResult (TE);
1375
+ } else if (BaseType->isDependentType ()) {
1376
+ R.setNotFoundInCurrentInstantiation ();
1377
+ return ExprEmpty ();
1377
1378
}
1378
1379
1379
1380
// Handle ivar access to Objective-C objects.
0 commit comments