@@ -3743,7 +3743,7 @@ Parser::ParseObjCOrigExpression(SourceLocation AtLoc) {
37433743// / \@init ( args )
37443744ExprResult
37453745Parser::ParseObjCInitExpression (SourceLocation AtLoc) {
3746- assert (Tok.isObjCAtKeyword (tok::objc_init) && " Not an @orig expression!" );
3746+ assert (Tok.isObjCAtKeyword (tok::objc_init) && " Not an @init expression!" );
37473747
37483748 SourceLocation OrigLoc = ConsumeToken (); // the 'orig' token
37493749
@@ -3765,25 +3765,33 @@ Parser::ParseObjCInitExpression(SourceLocation AtLoc) {
37653765
37663766 if (tok.is (tok::identifier))
37673767 {
3768- auto curDecs = getCurScope ()->getParent ()->decls ();
3769- for (auto dec : curDecs)
3768+ Scope* checkScope = getCurScope ();
3769+ bool found = false ;
3770+ while (checkScope && !found)
37703771 {
3771- if (dec->getKind () == Decl::ObjCGroup)
3772+ auto curDecs = checkScope->decls ();
3773+
3774+ for (auto dec : curDecs)
37723775 {
3773- auto gDec = dyn_cast<ObjCGroupDecl>(dec);
3774- std::string tokRaw = DeclarationName (tok.getIdentifierInfo ()).getAsString ();
3775- if (gDec ->getName ().str () == tokRaw)
3776+ if (dec->getKind () == Decl::ObjCGroup)
37763777 {
3777- ArgExprs.push_back (gDec );
3778- goto found;
3778+ auto gDec = dyn_cast<ObjCGroupDecl>(dec);
3779+ std::string tokRaw = DeclarationName (tok.getIdentifierInfo ()).getAsString ();
3780+ if (gDec ->getName ().str () == tokRaw)
3781+ {
3782+ ArgExprs.push_back (gDec );
3783+ found = true ;
3784+ break ;
3785+ }
37793786 }
37803787 }
3788+
3789+ checkScope = checkScope->getParent ();
37813790 }
3782- return ExprError (Diag (Tok, diag::err_expected_ident));
3783- }
37843791
3785- found:
3786- continue ;
3792+ if (!found)
3793+ return ExprError (Diag (Tok, diag::err_expected_ident));
3794+ }
37873795 }
37883796
37893797 return Actions.BuildObjCInitExpression (OrigLoc, ArgExprs, loc);
0 commit comments