-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
is_spark
property configuration pragma handling
This change fixes a bug in the `is_spark` property where configuration pragmas were not handled correctly: a `SPARK_Mode` configuration pragma in a package specification only applies to the package specification and does not affect the body (and vice-versa).
- Loading branch information
Showing
10 changed files
with
80 additions
and
6 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
3 changes: 3 additions & 0 deletions
3
testsuite/tests/properties/is_spark/configuration_pragma_5/test.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,3 @@ | ||
package body Test is | ||
procedure P is null; -- Off | ||
end Test; |
5 changes: 5 additions & 0 deletions
5
testsuite/tests/properties/is_spark/configuration_pragma_5/test.ads
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,5 @@ | ||
pragma SPARK_Mode (On); | ||
|
||
package Test is | ||
procedure P; | ||
end Test; |
6 changes: 6 additions & 0 deletions
6
testsuite/tests/properties/is_spark/configuration_pragma_5/test.out
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,6 @@ | ||
=== Analysing unit: <AnalysisUnit 'test.adb'> """ | ||
Subprogram <NullSubpDecl ["P"] test.adb:2:4-2:24> is skipped | ||
|
||
=== Analysing unit: <AnalysisUnit 'test2-p.adb'> """ | ||
Subprogram <SubpBody ["P"] test2-p.adb:2:1-5:7> is analyzed | ||
|
22 changes: 22 additions & 0 deletions
22
testsuite/tests/properties/is_spark/configuration_pragma_5/test.py
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,22 @@ | ||
""" | ||
This test checks that calling get_aspect/has_aspect/get_pragma/is_spark on a | ||
subprogram body node works as expected. | ||
""" | ||
import glob | ||
import libadalang as lal | ||
|
||
|
||
context = lal.AnalysisContext() | ||
context.set_config_pragmas_mapping(None, {}) | ||
|
||
for filename in sorted(glob.glob('*.ad[bs]')): | ||
unit = context.get_from_file(filename) | ||
subprograms = unit.root.findall(lal.BaseSubpBody) | ||
if subprograms: | ||
print('=== Analysing unit: ', unit, '"""') | ||
for subprogram in subprograms: | ||
print("Subprogram {} is {}".format( | ||
subprogram, | ||
"analyzed" if subprogram.p_is_spark() else "skipped" | ||
)) | ||
print('') |
1 change: 1 addition & 0 deletions
1
testsuite/tests/properties/is_spark/configuration_pragma_5/test.yaml
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 |
5 changes: 5 additions & 0 deletions
5
testsuite/tests/properties/is_spark/configuration_pragma_5/test2-p.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,5 @@ | ||
separate (Test2) | ||
procedure P is | ||
begin | ||
null; | ||
end P; |
5 changes: 5 additions & 0 deletions
5
testsuite/tests/properties/is_spark/configuration_pragma_5/test2.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,5 @@ | ||
pragma SPARK_Mode; | ||
|
||
package body Test2 is | ||
procedure P is separate; | ||
end Test2; |
5 changes: 5 additions & 0 deletions
5
testsuite/tests/properties/is_spark/configuration_pragma_5/test2.ads
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,5 @@ | ||
pragma SPARK_Mode; | ||
|
||
package Test2 is | ||
procedure P; | ||
end Test2; |
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,8 @@ | ||
type: bugfix | ||
title: Fix `p_is_spark` configuration pragma handling | ||
description: | | ||
This change fixes a bug in the `is_spark` property where configuration | ||
pragmas were not handled correctly: a `SPARK_Mode` configuration pragma in a | ||
package specification only applies to the package specification and does not | ||
affect the body (and vice-versa). | ||
date: 2023-09-12 |