-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix uninitialized memory when using %domain construct.
- Loading branch information
Showing
6 changed files
with
77 additions
and
1 deletion.
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
20 changes: 20 additions & 0 deletions
20
testsuite/tests/properties/domain_node/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,20 @@ | ||
import lexer_example | ||
|
||
@with_lexer(foo_lexer) | ||
grammar foo_grammar { | ||
@main_rule main_rule <- Example("example") | ||
} | ||
|
||
@abstract | ||
class FooNode implements Node[FooNode] { | ||
v: LogicVar | ||
} | ||
|
||
class Example: FooNode { | ||
fun identity(): Entity[Example] = self | ||
|
||
@exported | ||
fun test(): Bool = ( | ||
%domain(node.v, [node]) and %eq(node.v, node.v, conv_prop=Example.identity) | ||
).solve() | ||
} |
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,19 @@ | ||
with Ada.Text_IO; use Ada.Text_IO; | ||
|
||
with Libfoolang.Analysis; use Libfoolang.Analysis; | ||
|
||
procedure Main is | ||
Ctx : constant Analysis_Context := Create_Context; | ||
U : constant Analysis_Unit := Ctx.Get_From_Buffer | ||
(Filename => "main.txt", Buffer => "example"); | ||
|
||
Node : constant Example := U.Root.As_Example; | ||
Dummy : Boolean; | ||
begin | ||
if U.Has_Diagnostics then | ||
Put_Line ("Parsing errors..."); | ||
return; | ||
end if; | ||
Dummy := Node.P_Test; | ||
Put_Line ("main.adb: Done."); | ||
end Main; |
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,2 @@ | ||
main.adb: Done. | ||
Done |
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,32 @@ | ||
""" | ||
Test that using the ``domain`` DSL construct with bare nodes does not set | ||
uninitialized data into the corresponding logic variable. | ||
""" | ||
|
||
from langkit.dsl import ASTNode, T, UserField | ||
from langkit.expressions import Bind, Entity, Self, langkit_property | ||
|
||
from utils import build_and_run | ||
|
||
|
||
class FooNode(ASTNode): | ||
v = UserField(type=T.LogicVar, public=False) | ||
|
||
|
||
class Example(FooNode): | ||
@langkit_property(return_type=T.Example.entity) | ||
def identity(): | ||
return Entity | ||
|
||
@langkit_property(public=True) | ||
def test(): | ||
return (Self.v.domain([Self]) & | ||
Bind(Self.v, Self.v, conv_prop=Example.identity)).solve | ||
|
||
|
||
build_and_run( | ||
lkt_file='expected_concrete_syntax.lkt', | ||
gpr_mains=['main.adb'], | ||
types_from_lkt=True, | ||
) | ||
print('Done') |
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 @@ | ||
driver: python |