Skip to content

Commit e2733c8

Browse files
authored
[flang] Accept useless label on top-level FUNCTION (#129603)
The look-ahead parser for function program units didn't allow for a useless label on the statement. Fixes #129456.
1 parent 68e3c02 commit e2733c8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

flang/lib/Parser/program-parsers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static constexpr auto programUnit{
6464
construct<ProgramUnit>(indirect(subroutineSubprogram)) ||
6565
construct<ProgramUnit>(indirect(Parser<Submodule>{})) ||
6666
construct<ProgramUnit>(indirect(Parser<BlockData>{})) ||
67-
lookAhead(validFunctionStmt) >>
67+
lookAhead(maybe(label) >> validFunctionStmt) >>
6868
construct<ProgramUnit>(indirect(functionSubprogram)) ||
6969
construct<ProgramUnit>(indirect(Parser<MainProgram>{}))};
7070
static constexpr auto normalProgramUnit{StartNewSubprogram{} >> programUnit /

flang/test/Parser/func-label.f

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
! RUN: %flang_fc1 -fsyntax-only -pedantic %s 2>&1 | FileCheck --allow-empty %s
2+
!CHECK-NOT: error:
3+
1 function fun()
4+
2 end function
5+
3 write(6,*) "pass"
6+
4 end
7+

0 commit comments

Comments
 (0)