@@ -150,11 +150,12 @@ TYPE_PARSER(sourced(construct<AccLoopDirective>(
150150TYPE_PARSER(construct<AccBeginLoopDirective>(
151151    sourced (Parser<AccLoopDirective>{}), Parser<AccClauseList>{}))
152152
153- TYPE_PARSER(construct<AccEndLoop>(startAccLine >>  " END LOOP"  _tok))
153+ TYPE_PARSER(construct<AccEndLoop>(" END LOOP"  _tok))
154154
155155TYPE_PARSER(construct<OpenACCLoopConstruct>(
156156    sourced (Parser<AccBeginLoopDirective>{} / endAccLine),
157-     maybe(Parser<DoConstruct>{}), maybe(Parser<AccEndLoop>{} / endAccLine)))
157+     maybe(Parser<DoConstruct>{}),
158+     maybe(startAccLine >> Parser<AccEndLoop>{} / endAccLine)))
158159
159160//  2.15.1 Routine directive
160161TYPE_PARSER(sourced(construct<OpenACCRoutineConstruct>(verbatim(" ROUTINE"  _tok),
@@ -227,22 +228,25 @@ TYPE_PARSER(construct<OpenACCStandaloneConstruct>(
227228TYPE_PARSER(construct<OpenACCStandaloneDeclarativeConstruct>(
228229    sourced (Parser<AccDeclarativeDirective>{}), Parser<AccClauseList>{}))
229230
230- TYPE_PARSER(
231-     startAccLine >> first (sourced(construct<OpenACCDeclarativeConstruct>(
232-                               Parser<OpenACCStandaloneDeclarativeConstruct>{})),
233-                         sourced(construct<OpenACCDeclarativeConstruct>(
234-                             Parser<OpenACCRoutineConstruct>{}))))
231+ TYPE_PARSER(startAccLine >>
232+     withMessage (" expected OpenACC directive"  _err_en_US,
233+         first (sourced(construct<OpenACCDeclarativeConstruct>(
234+                   Parser<OpenACCStandaloneDeclarativeConstruct>{})),
235+             sourced(construct<OpenACCDeclarativeConstruct>(
236+                 Parser<OpenACCRoutineConstruct>{})))))
235237
236238//  OpenACC constructs
237239TYPE_CONTEXT_PARSER(" OpenACC construct"  _en_US,
238240    startAccLine >>
239-         first (construct<OpenACCConstruct>(Parser<OpenACCBlockConstruct>{}),
240-             construct<OpenACCConstruct>(Parser<OpenACCCombinedConstruct>{}),
241-             construct<OpenACCConstruct>(Parser<OpenACCLoopConstruct>{}),
242-             construct<OpenACCConstruct>(Parser<OpenACCStandaloneConstruct>{}),
243-             construct<OpenACCConstruct>(Parser<OpenACCCacheConstruct>{}),
244-             construct<OpenACCConstruct>(Parser<OpenACCWaitConstruct>{}),
245-             construct<OpenACCConstruct>(Parser<OpenACCAtomicConstruct>{})))
241+         withMessage (" expected OpenACC directive"  _err_en_US,
242+             first (construct<OpenACCConstruct>(Parser<OpenACCBlockConstruct>{}),
243+                 construct<OpenACCConstruct>(Parser<OpenACCCombinedConstruct>{}),
244+                 construct<OpenACCConstruct>(Parser<OpenACCLoopConstruct>{}),
245+                 construct<OpenACCConstruct>(
246+                     Parser<OpenACCStandaloneConstruct>{}),
247+                 construct<OpenACCConstruct>(Parser<OpenACCCacheConstruct>{}),
248+                 construct<OpenACCConstruct>(Parser<OpenACCWaitConstruct>{}),
249+                 construct<OpenACCConstruct>(Parser<OpenACCAtomicConstruct>{}))))
246250
247251TYPE_PARSER(startAccLine >>
248252    sourced (construct<AccEndCombinedDirective>(sourced(" END"  _tok >>
0 commit comments