@@ -1323,24 +1323,24 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R,
1323
1323
if (IsArrow) {
1324
1324
if (const PointerType *Ptr = BaseType->getAs <PointerType>())
1325
1325
BaseType = Ptr->getPointeeType ();
1326
- else if (!BaseType->isDependentType ()) {
1326
+ else if (BaseType->getAsRecordDecl ()) {
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->isDependentType ()) {
1327
1341
if (const ObjCObjectPointerType *Ptr =
1328
- BaseType->getAs <ObjCObjectPointerType>())
1342
+ BaseType->getAs <ObjCObjectPointerType>()) {
1329
1343
BaseType = Ptr->getPointeeType ();
1330
- else if (BaseType->isRecordType ()) {
1331
- // Recover from arrow accesses to records, e.g.:
1332
- // struct MyRecord foo;
1333
- // foo->bar
1334
- // This is actually well-formed in C++ if MyRecord has an
1335
- // overloaded operator->, but that should have been dealt with
1336
- // by now--or a diagnostic message already issued if a problem
1337
- // was encountered while looking for the overloaded operator->.
1338
- if (!S.getLangOpts ().CPlusPlus ) {
1339
- S.Diag (OpLoc, diag::err_typecheck_member_reference_suggestion)
1340
- << BaseType << int (IsArrow) << BaseExpr.get ()->getSourceRange ()
1341
- << FixItHint::CreateReplacement (OpLoc, " ." );
1342
- }
1343
- IsArrow = false ;
1344
1344
} else if (BaseType->isFunctionType ()) {
1345
1345
goto fail;
1346
1346
} else {
0 commit comments