From a0c5c76fff7868e2dd0c96dbe15a21a957afcac1 Mon Sep 17 00:00:00 2001 From: Matthieu Eyraud Date: Thu, 7 Dec 2023 15:27:36 +0100 Subject: [PATCH] [TGen] deal gracefully with Global => null aspect TGen used to crash on such occurrences. Simply skip the null expression. --- src/tgen/tgen-types-translation.adb | 5 ++ testsuite/tests/test/tgen_globals/test.out | 68 ++++++++++--------- .../tests/test/tgen_globals/test/pkg.adb | 1 + .../tests/test/tgen_globals/test/pkg.ads | 2 + 4 files changed, 45 insertions(+), 31 deletions(-) diff --git a/src/tgen/tgen-types-translation.adb b/src/tgen/tgen-types-translation.adb index 25bcb448..94c90647 100644 --- a/src/tgen/tgen-types-translation.adb +++ b/src/tgen/tgen-types-translation.adb @@ -3111,6 +3111,11 @@ package body TGen.Types.Translation is procedure Process_Global (N : LAL.Name) is Global : constant Basic_Decl := N.P_Referenced_Decl; begin + -- Ignore cases such as Global => null + + if Global.Is_Null then + return; + end if; if Kind (Global) = Ada_Object_Decl then declare diff --git a/testsuite/tests/test/tgen_globals/test.out b/testsuite/tests/test/tgen_globals/test.out index 9eb664cd..0bdc923a 100644 --- a/testsuite/tests/test/tgen_globals/test.out +++ b/testsuite/tests/test/tgen_globals/test.out @@ -30,51 +30,57 @@ Pkg.Supported_Global is 1954668933 Pkg.Supported_Global is 1954668933 Pkg.Supported_Global is 1954668933 Pkg.Supported_Global is 3 -Pkg.Supported_Global is 18834966 -Pkg.Supported_Global is 378901556 Pkg.Supported_Global is 5743901 Pkg.Supported_Global is -9 Pkg.Supported_Global is -280550153 +Pkg.Supported_Global is 18183605 +Pkg.Supported_Global is 8 +pkg.ads:14:4: info: corresponding test PASSED +pkg.ads:14:4: info: corresponding test PASSED +pkg.ads:14:4: info: corresponding test PASSED +pkg.ads:14:4: info: corresponding test PASSED +pkg.ads:14:4: info: corresponding test PASSED +pkg.ads:14:4: info: corresponding test PASSED +pkg.ads:24:4: info: corresponding test PASSED +pkg.ads:24:4: info: corresponding test PASSED +pkg.ads:24:4: info: corresponding test PASSED +pkg.ads:24:4: info: corresponding test PASSED +pkg.ads:24:4: info: corresponding test PASSED +pkg.ads:24:4: info: corresponding test PASSED +pkg.ads:21:4: info: corresponding test PASSED +pkg.ads:21:4: info: corresponding test PASSED +pkg.ads:21:4: info: corresponding test PASSED +pkg.ads:21:4: info: corresponding test PASSED +pkg.ads:21:4: info: corresponding test PASSED +pkg.ads:21:4: info: corresponding test PASSED +pkg.ads:27:4: info: corresponding test PASSED +pkg.ads:27:4: info: corresponding test PASSED +pkg.ads:27:4: info: corresponding test PASSED +pkg.ads:27:4: info: corresponding test PASSED +pkg.ads:27:4: info: corresponding test PASSED +pkg.ads:27:4: info: corresponding test PASSED pkg.ads:12:4: info: corresponding test PASSED pkg.ads:12:4: info: corresponding test PASSED pkg.ads:12:4: info: corresponding test PASSED pkg.ads:12:4: info: corresponding test PASSED pkg.ads:12:4: info: corresponding test PASSED -pkg.ads:12:4: info: corresponding test PASSED -pkg.ads:22:4: info: corresponding test PASSED -pkg.ads:22:4: info: corresponding test PASSED -pkg.ads:22:4: info: corresponding test PASSED -pkg.ads:22:4: info: corresponding test PASSED -pkg.ads:22:4: info: corresponding test PASSED -pkg.ads:22:4: info: corresponding test PASSED -pkg.ads:19:4: info: corresponding test PASSED -pkg.ads:19:4: info: corresponding test PASSED -pkg.ads:19:4: info: corresponding test PASSED -pkg.ads:19:4: info: corresponding test PASSED -pkg.ads:19:4: info: corresponding test PASSED -pkg.ads:19:4: info: corresponding test PASSED -pkg.ads:25:4: info: corresponding test PASSED -pkg.ads:25:4: info: corresponding test PASSED -pkg.ads:25:4: info: corresponding test PASSED -pkg.ads:25:4: info: corresponding test PASSED -pkg.ads:25:4: info: corresponding test PASSED -pkg.ads:25:4: info: corresponding test PASSED +pkg.ads:18:4: info: corresponding test PASSED +pkg.ads:18:4: info: corresponding test PASSED +pkg.ads:18:4: info: corresponding test PASSED +pkg.ads:18:4: info: corresponding test PASSED +pkg.ads:18:4: info: corresponding test PASSED +pkg.ads:18:4: info: corresponding test PASSED pkg.ads:16:4: info: corresponding test PASSED pkg.ads:16:4: info: corresponding test PASSED pkg.ads:16:4: info: corresponding test PASSED pkg.ads:16:4: info: corresponding test PASSED pkg.ads:16:4: info: corresponding test PASSED pkg.ads:16:4: info: corresponding test PASSED -pkg.ads:14:4: info: corresponding test PASSED -pkg.ads:14:4: info: corresponding test PASSED -pkg.ads:14:4: info: corresponding test PASSED -pkg.ads:14:4: info: corresponding test PASSED -pkg.ads:14:4: info: corresponding test PASSED -pkg.ads:14:4: info: corresponding test PASSED pkg.ads:12:4: error: corresponding test FAILED: Test not implemented. (pkg-test_data-tests.adb:45) pkg.ads:14:4: error: corresponding test FAILED: Test not implemented. (pkg-test_data-tests.adb:66) pkg.ads:16:4: error: corresponding test FAILED: Test not implemented. (pkg-test_data-tests.adb:87) -pkg.ads:19:4: error: corresponding test FAILED: Test not implemented. (pkg-test_data-tests.adb:108) -pkg.ads:22:4: error: corresponding test FAILED: Test not implemented. (pkg-test_data-tests.adb:129) -pkg.ads:25:4: error: corresponding test FAILED: Test not implemented. (pkg-test_data-tests.adb:150) -42 tests run: 36 passed; 6 failed; 0 crashed. +pkg.ads:18:4: error: corresponding test FAILED: Test not implemented. (pkg-test_data-tests.adb:108) +pkg.ads:21:4: error: corresponding test FAILED: Test not implemented. (pkg-test_data-tests.adb:129) +pkg.ads:24:4: error: corresponding test FAILED: Test not implemented. (pkg-test_data-tests.adb:150) +pkg.ads:27:4: error: corresponding test FAILED: Test not implemented. (pkg-test_data-tests.adb:171) +48 tests run: 41 passed; 7 failed; 0 crashed. diff --git a/testsuite/tests/test/tgen_globals/test/pkg.adb b/testsuite/tests/test/tgen_globals/test/pkg.adb index d4ca8330..31dac327 100644 --- a/testsuite/tests/test/tgen_globals/test/pkg.adb +++ b/testsuite/tests/test/tgen_globals/test/pkg.adb @@ -2,6 +2,7 @@ with Ada.Text_IO; use Ada.Text_IO; package body Pkg is + procedure Test_Null (B : Boolean) is null; procedure Test_Cst (B : Boolean) is null; procedure Test_Supported (B : Boolean) is diff --git a/testsuite/tests/test/tgen_globals/test/pkg.ads b/testsuite/tests/test/tgen_globals/test/pkg.ads index 16bb1e05..ce5f5b43 100644 --- a/testsuite/tests/test/tgen_globals/test/pkg.ads +++ b/testsuite/tests/test/tgen_globals/test/pkg.ads @@ -9,6 +9,8 @@ package Pkg is Cst : constant Integer := 2; + procedure Test_Null (B : Boolean) with Global => null; + procedure Test_Cst (B : Boolean) with Global => Cst; procedure Test_Supported (B : Boolean) with Global => Supported_Global;