diff --git a/src/test-generation.adb b/src/test-generation.adb index e63b5a68..84582bbe 100644 --- a/src/test-generation.adb +++ b/src/test-generation.adb @@ -69,6 +69,15 @@ package body Test.Generation is return Over; end if; + -- Skip any non-instantiated generic decl, they will be processed as + -- part of a generic instantiation, if any. + + if Node.Kind in Ada_Generic_Decl + and then Node.P_Generic_Instantiations'Length = 0 + then + return Over; + end if; + -- Collect all types used as parameters in subprogram declarations. -- Skip generic subprogram declarations as we only care about the -- instantiations. Also skip subprograms with zero parameters if there @@ -86,14 +95,6 @@ package body Test.Generation is | Ada_Subp_Renaming_Decl then - -- Skip generic subp decls (these will be processed if they are - -- instantiated). - - if Node.As_Basic_Decl.P_Canonical_Part.Kind in Ada_Generic_Decl - then - return Over; - end if; - -- Check, if the subprogram has zero parameters. If so, only add it -- to the generation context if it has a global annotation. diff --git a/testsuite/tests/test/183-formal_params/gen.adb b/testsuite/tests/test/183-formal_params/gen.adb new file mode 100644 index 00000000..cf79cc65 --- /dev/null +++ b/testsuite/tests/test/183-formal_params/gen.adb @@ -0,0 +1,10 @@ +package body Gen is + + procedure Params (X : T) is + begin + null; + end Params; + + function Ret return T is (Val); + +end Gen; diff --git a/testsuite/tests/test/183-formal_params/gen.ads b/testsuite/tests/test/183-formal_params/gen.ads new file mode 100644 index 00000000..02a50d1a --- /dev/null +++ b/testsuite/tests/test/183-formal_params/gen.ads @@ -0,0 +1,7 @@ +generic + type T is range <>; + Val : T; +package Gen is + procedure Params (X : T); + function Ret return T; +end Gen; \ No newline at end of file diff --git a/testsuite/tests/test/183-formal_params/importing.ads b/testsuite/tests/test/183-formal_params/importing.ads new file mode 100644 index 00000000..4c397ed9 --- /dev/null +++ b/testsuite/tests/test/183-formal_params/importing.ads @@ -0,0 +1,5 @@ +with Gen; + +package Importing is + +end Importing; diff --git a/testsuite/tests/test/183-formal_params/prj.gpr b/testsuite/tests/test/183-formal_params/prj.gpr new file mode 100644 index 00000000..1c32e054 --- /dev/null +++ b/testsuite/tests/test/183-formal_params/prj.gpr @@ -0,0 +1,5 @@ +project Prj is + + for Object_Dir use "obj"; + +end Prj; diff --git a/testsuite/tests/test/183-formal_params/test.out b/testsuite/tests/test/183-formal_params/test.out new file mode 100644 index 00000000..5461b50b --- /dev/null +++ b/testsuite/tests/test/183-formal_params/test.out @@ -0,0 +1,7 @@ +No subprogram supported for test case generation. +Units remaining: 3 Units remaining: 2 Units remaining: 1 warning: (gnattest) gen.ads:1:1: no instance of Gen + corresponding tests are not included into harness +gnattest: no test skeletons generated because no subprogram to test + found in project /prj.gpr +gnattest: cannot create main suite and test runner +>>>program returned status code 1 diff --git a/testsuite/tests/test/183-formal_params/test.sh b/testsuite/tests/test/183-formal_params/test.sh new file mode 100644 index 00000000..4b5a8786 --- /dev/null +++ b/testsuite/tests/test/183-formal_params/test.sh @@ -0,0 +1,5 @@ +#! /bin/bash + +# We expect only diagnostics stating that there are no +# subprograms to test, not that some type is unsupported. +gnattest -P prj.gpr --gen-test-vectors diff --git a/testsuite/tests/test/183-formal_params/test.yaml b/testsuite/tests/test/183-formal_params/test.yaml new file mode 100644 index 00000000..6665c4a3 --- /dev/null +++ b/testsuite/tests/test/183-formal_params/test.yaml @@ -0,0 +1,7 @@ +description: Test that gnattest does not attempt to generate test inputs for + subprograms with generic formal parameters or return types. + +driver: shell_script + +control: + - [XFAIL, 'x86', 'Marshalling not working for 32bits (UB03-008)'] diff --git a/testsuite/tests/test/tc_json_dump_with_gen/test.out b/testsuite/tests/test/tc_json_dump_with_gen/test.out index 422ef15c..526d695a 100644 --- a/testsuite/tests/test/tc_json_dump_with_gen/test.out +++ b/testsuite/tests/test/tc_json_dump_with_gen/test.out @@ -1,3 +1,6 @@ +gnattest: Error while processing : +my_file.ident.X: my_file.ident.t is not supported (Generic formal types are unsupported) + Units remaining: 2 Units remaining: 1 my_file.ads:14:4: info: corresponding test PASSED my_file.ads:14:4: info: corresponding test PASSED