@@ -957,13 +957,15 @@ OutputDesc *ScriptParser::readOverlaySectionDescription() {
957957 OutputDesc *osd = script->createOutputSection (next (), getCurrentLocation ());
958958 osd->osec .inOverlay = true ;
959959 expect (" {" );
960- while (! errorCount () && ! consume (" }" )) {
960+ while (auto tok = till (" }" )) {
961961 uint64_t withFlags = 0 ;
962962 uint64_t withoutFlags = 0 ;
963- if (consume ( " INPUT_SECTION_FLAGS" ))
963+ if (tok == " INPUT_SECTION_FLAGS" ) {
964964 std::tie (withFlags, withoutFlags) = readInputSectionFlags ();
965+ tok = till (" " );
966+ }
965967 osd->osec .commands .push_back (
966- readInputSectionRules (next () , withFlags, withoutFlags));
968+ readInputSectionRules (tok , withFlags, withoutFlags));
967969 }
968970 osd->osec .phdrs = readOutputSectionPhdrs ();
969971 return osd;
@@ -1090,7 +1092,7 @@ SymbolAssignment *ScriptParser::readProvideHidden(bool provide, bool hidden) {
10901092 StringRef name = next (), eq = peek ();
10911093 if (eq != " =" ) {
10921094 setError (" = expected, but got " + next ());
1093- while (! atEOF () && next () != " )" )
1095+ while (till ( " )" ) )
10941096 ;
10951097 return nullptr ;
10961098 }
@@ -1731,15 +1733,11 @@ ScriptParser::readSymbols() {
17311733 SmallVector<SymbolVersion, 0 > globals;
17321734 SmallVector<SymbolVersion, 0 > *v = &globals;
17331735
1734- while (!errorCount ()) {
1735- if (consume (" }" ))
1736- break ;
1737-
1738- if (consume (" extern" )) {
1736+ while (auto tok = till (" }" )) {
1737+ if (tok == " extern" ) {
17391738 SmallVector<SymbolVersion, 0 > ext = readVersionExtern ();
17401739 v->insert (v->end (), ext.begin (), ext.end ());
17411740 } else {
1742- StringRef tok = next ();
17431741 if (tok == " local:" || (tok == " local" && consume (" :" ))) {
17441742 v = &locals;
17451743 continue ;
0 commit comments