forked from AdaCore/langkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'topic/v810-011' into 'master'
Ada API: fix a stack overflow in Children_And_Trivia Closes AdaCore#651 See merge request eng/libadalang/langkit!742
- Loading branch information
Showing
10 changed files
with
4,270 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
testsuite/tests/ada_api/children_and_trivia_stack_overflow/expected_concrete_syntax.lkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import lexer_example | ||
|
||
@with_lexer(foo_lexer) | ||
grammar foo_grammar { | ||
@main_rule main_rule <- list*(id) | ||
id <- Identifier(@identifier) | ||
} | ||
|
||
@abstract class FooNode implements Node[FooNode] { | ||
} | ||
|
||
class Identifier : FooNode implements TokenNode { | ||
} |
25 changes: 25 additions & 0 deletions
25
testsuite/tests/ada_api/children_and_trivia_stack_overflow/main.adb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
with Ada.Text_IO; use Ada.Text_IO; | ||
|
||
with Libfoolang.Analysis; use Libfoolang.Analysis; | ||
with Libfoolang.Common; use Libfoolang.Common; | ||
|
||
procedure Main is | ||
U : constant Analysis_Unit := | ||
Create_Context.Get_From_File ("main.txt"); | ||
|
||
Child_Counter, Trivia_Counter : Natural := 0; | ||
begin | ||
-- This call to Children_And_Trivia raises a STORAGE_ERROR (stack overflow) | ||
-- if the nodes are stored on the stack. | ||
|
||
for N of U.Root.Children_And_Trivia loop | ||
if N.Kind = Child then | ||
Child_Counter := Child_Counter + 1; | ||
else | ||
Trivia_Counter := Trivia_Counter + 1; | ||
end if; | ||
end loop; | ||
Put_Line ("Child:" & Child_Counter'Image); | ||
Put_Line ("Trivia:" & Trivia_Counter'Image); | ||
Put_Line ("main.adb: Done."); | ||
end Main; |
Oops, something went wrong.