Skip to content

Commit e6e4c6b

Browse files
committed
[Fortran/gfortran] Enable some "compile" tests
Enable the 'compile' tests from all the directories under Fortran/gfortran/regression (except for the tests in regression itself). Disable those tests that fail.
1 parent 32eebe5 commit e6e4c6b

25 files changed

+448
-71
lines changed

Fortran/gfortran/README.md

Lines changed: 81 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,41 @@ This is the top-level directory for tests imported from
44
[GCC](https://github.com/gcc-mirror/gcc). The test files are contained within
55
two subdirectories:
66

7-
- `regression`: Contains the gfortran [tests](https://github.com/gcc-mirror/gcc/tree/master/gcc/testsuite/gfortran.dg).
8-
- `torture`: Contains the gfortran [torture tests](https://github.com/gcc-mirror/gcc/tree/master/gcc/testsuite/gfortran.fortran-torture).
7+
- `regression`: Contains the gfortran [tests](https://github.com/gcc-mirror/gcc/tree/master/gcc/testsuite/gfortran.dg).
8+
- `torture`: Contains the gfortran [torture tests](https://github.com/gcc-mirror/gcc/tree/master/gcc/testsuite/gfortran.fortran-torture).
99

1010
The tests in both `regression` (and its subdirectories) and `torture` can be
1111
classified roughly as _compile_ tests and _execute_ tests. The _compile_ tests
1212
generally check the compiler's error/warning messages and, in some cases,
1313
optimization logs. The _execute_ tests are end-to-end tests that check the
1414
behavior of the binary produced by the compiler.
1515

16-
Currently, only the _execute_ tests are supported in `regression`. Both
16+
Currently, only the _execute_ tests are supported in `regression`. Both
1717
`compile` and `execute` tests have been enabled in `torture`.
1818

1919
Of the supported tests, a number of tests have been disabled. There are four
2020
categories of such tests:
2121

22-
- *Unsupported*: These are tests that use non-standard extensions/intrinsics
23-
that are not currently supported by flang. Unless those non-standard
24-
features are supported in the future, these tests will never be enabled.
22+
- *Unsupported*: These are tests that use non-standard extensions/intrinsics
23+
that are not currently supported by flang. Unless those non-standard
24+
features are supported in the future, these tests will never be enabled.
2525

26-
- *Unimplemented*: These tests hit a "not yet implemented" assertion within
27-
flang.
26+
- *Unimplemented*: These tests hit a "not yet implemented" assertion within
27+
flang.
2828

29-
- *Skipped*: These tests cause some form of compiler error. Some trigger an
30-
assertion within the compiler. Others are legal Fortran programs, but
31-
nevertheless cause a semantic error, most likely due to unimplemented
32-
features.
29+
- *Skipped*: These tests cause some form of compiler error. Some trigger an
30+
assertion within the compiler. Others are legal Fortran programs, but
31+
nevertheless cause a semantic error, most likely due to unimplemented
32+
features.
3333

34-
- *Failing*: These tests fail at runtime - some crash on execution, others
35-
produce incorrect/unexpected output. This could be a result of a bug in the
36-
compiler/code generator or the runtime.
34+
- *Failing*: These tests fail at test-time.
35+
36+
- For "execute" tests, some crash on execution, others produce
37+
incorrect/unexpected output. This could be a result of a bug in the
38+
compiler/code generator or the runtime.
39+
40+
- For "compile" tests, this could be because the compilation succeeds when it
41+
is expected to fail, or vice versa.
3742

3843
Over time, the number of tests in the *unimplemented*, *skipped*, and *failing*
3944
categories should decrease. Eventually, only the *unsupported* category should
@@ -42,8 +47,8 @@ remain.
4247

4348
### _Compile_ tests ###
4449

45-
The _compile_ tests are "built" when the whole test suite is built at which
46-
time a compilation log is saved. At testing time, the log is checked to
50+
The _compile_ tests are "built" when the whole test suite is built at which
51+
time a compilation log is saved. At testing time, the log is checked to
4752
determine whether the test should pass or fail. If the test is expected to pass,
4853
but the compilation log contains errors, the test will be deemed to have failed
4954
and vice versa. The _compile_ test are supported in `torture`, but not in
@@ -66,11 +71,11 @@ default.
6671
In order to enable the disabled tests, one or more of the following options can
6772
be passed to `cmake`:
6873

69-
- `TEST_SUITE_FORTRAN_FORCE_ALL_TESTS`: Enable all disabled tests.
70-
- `TEST_SUITE_FORTRAN_FORCE_UNSUPPORTED_TESTS`: Enable only the *unsupported* tests.
71-
- `TEST_SUITE_FORTRAN_FORCE_UNIMPLEMENTED_TESTS`: Enable only the *unimplemented* tests.
72-
- `TEST_SUITE_FORTRAN_FORCE_SKIPPED_TESTS`: Enable only the *skipped* tests.
73-
- `TEST_SUITE_FORTRAN_FORCE_FAILING_TESTS`: Enable only the *failing* tests.
74+
- `TEST_SUITE_FORTRAN_FORCE_ALL_TESTS`: Enable all disabled tests.
75+
- `TEST_SUITE_FORTRAN_FORCE_UNSUPPORTED_TESTS`: Enable only the *unsupported* tests.
76+
- `TEST_SUITE_FORTRAN_FORCE_UNIMPLEMENTED_TESTS`: Enable only the *unimplemented* tests.
77+
- `TEST_SUITE_FORTRAN_FORCE_SKIPPED_TESTS`: Enable only the *skipped* tests.
78+
- `TEST_SUITE_FORTRAN_FORCE_FAILING_TESTS`: Enable only the *failing* tests.
7479

7580
Some of the tests require the `ISO_Fortran_binding.h` header file. `cmake` will
7681
look for this file in the `include` directory of the `flang` installation
@@ -116,3 +121,57 @@ manually periodically.
116121

117122
The test files in `regression` and `torture` *must not* be modified.
118123

124+
125+
### TODO's ###
126+
127+
If some of the items listed here are implemented, even in part, it should
128+
allows us to make better use of the test-suite.
129+
130+
Several DejaGNU directives from the test files are currently ignored. In some
131+
cases, those directives check that the language feature/optimization being
132+
exercised by the tests is actually handled correctly. By ignoring them, we are
133+
simply checking that `flang` (or the code produced by it) does not crash at
134+
build/test time. In the case of the _compile_ tests where this is the case, we
135+
could have situations where the test passes because the compilation succeeded,
136+
not because the compiler actually did the right thing - for instance, the tests
137+
in `gfortran/regression/vect` check if the code was correctly vectorized. We
138+
could pass those tests just by failing to crash - not because `flang` actually
139+
vectorized the code.
140+
141+
It is not clear how much effort would be involved in correctly handling all the
142+
DejaGNU directives.
143+
144+
### `dg-error` directive ###
145+
146+
The `dg-error` directive indicates that the test should fail to compile with a
147+
particular error. Obviously, this is a `gfortran`-specific error. `flang` may
148+
not have a direct equivalent i.e. it may produce a more general error message
149+
(or maybe even a more specific one if `gfortran` is the one with the more
150+
general error message). For now, when a`dg-error` is encountered, the test is
151+
marked as `expect-error`. At test time, we only check if "some" error (that was
152+
not a crash) occurred. This can cause false-negatives, particularly in the
153+
OpenMP (and perhaps even OpenACC) tests. This is where some directives/clauses
154+
are currently not implemented which results in a parse error (as opposed to the
155+
triggering of a "not-yet-implemented" assertion) which is also deemed an "error",
156+
thereby causing the test to pass.
157+
158+
#### `scan-tree-dump` directive ####
159+
160+
In the _compile_ tests, the `dg-final { scan-tree-dump* ...}` directives are
161+
ignored. The `scan-tree-dump*` checks GCC's internal tree structure to ensure
162+
that the specific language feature/optimization the test was meant to exercise
163+
was handled correctly (see, for example, `regression/volatile_7.f90`).
164+
165+
The tests instruct GCC to write out the internal representation to file and scan
166+
the file for the presence or absence of certain text. To capture the same
167+
behavior here, we would need to parse and translate the internal representation
168+
of GCC to an equivalent representation in LLVM IR.
169+
170+
### `target` directive ###
171+
172+
The `target` directive is used to restrict tests to run on certain
173+
platforms/systems. Currently, the target directive is ignored entirely and the
174+
tests are always run. Currently, the gfortran tests are only enabled on *nix on
175+
x86-64 and aarch64 and ignoring the directive seems to be ok. As support for
176+
more systems and architectures are added, these directives will need to be
177+
handled correctly.

Fortran/gfortran/regression/analyzer/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@
99
set(TESTS)
1010
gfortran_populate_tests(TESTS)
1111
gfortran_add_execute_tests_from("${TESTS}")
12-
# TODO: Enable the "compile" tests.
13-
# gfortran_add_compile_tests_from("${TESTS}")
12+
gfortran_add_compile_tests_from("${TESTS}")

Fortran/gfortran/regression/analyzer/DisabledFiles.cmake

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,21 @@
99
# There are currently no unsupported files.
1010
set(UNSUPPORTED_FILES "")
1111

12-
# There are currently no unimplemented files.
13-
set(UNIMPLEMENTED_FILES "")
12+
# These tests are disabled because they trigger "not yet implemented"
13+
# assertions.
14+
file(GLOB UNIMPLEMENTED_FILES CONFIGURE_DEPENDS
15+
# unimplemented: allocatable components in derived type assignment
16+
pr93777.f90
17+
18+
# unimplemented: gather rhs LEN parameters in assignment to allocatable
19+
deferred_character_25.f90
20+
)
1421

1522
# There are currently no skipped files.
1623
set(SKIPPED_FILES "")
1724

18-
# There are currently no failing files.
19-
set(FAILING_FILES "")
25+
# There tests fail when they are expected to pass.
26+
file(GLOB FAILING_FILES CONFIGURE_DEPENDS
27+
# These files fail to compile when compilation is expected to succeed.
28+
malloc.f90
29+
malloc-example.f90)

Fortran/gfortran/regression/asan/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@
99
set(TESTS)
1010
gfortran_populate_tests(TESTS)
1111
gfortran_add_execute_tests_from("${TESTS}")
12-
# TODO: Enable the "compile" tests.
13-
# gfortran_add_compile_tests_from("${TESTS}")
12+
gfortran_add_compile_tests_from("${TESTS}")

Fortran/gfortran/regression/asan/DisabledFiles.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
# There are currently no unsupported files.
1010
set(UNSUPPORTED_FILES "")
1111

12-
# There are currently no unimplemented files.
13-
set(UNIMPLEMENTED_FILES "")
12+
# These tests are disabled because they trigger a "not yet implemented"
13+
# assertion.
14+
file(GLOB UNIMPLEMENTED_FILES CONFIGURE_DEPENDS
15+
# unimplemented: character array expression temp with dynamic length
16+
associate_58.f90
17+
associate_59.f90
18+
)
1419

1520
# These tests trigger internal compiler errors.
1621
file(GLOB SKIPPED_FILES CONFIGURE_DEPENDS

Fortran/gfortran/regression/c-interop/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@
99
set(TESTS)
1010
gfortran_populate_tests(TESTS)
1111
gfortran_add_execute_tests_from("${TESTS}")
12-
# TODO: Enable the "compile" tests.
13-
# gfortran_add_compile_tests_from("${TESTS}")
12+
gfortran_add_compile_tests_from("${TESTS}")

Fortran/gfortran/regression/c-interop/DisabledFiles.cmake

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ file(GLOB UNIMPLEMENTED_FILES CONFIGURE_DEPENDS
2020
argument-association-assumed-rank-6.f90
2121
argument-association-assumed-rank-7.f90
2222
argument-association-assumed-rank-8.f90
23+
c535a-1.f90
2324
cf-out-descriptor-6.f90
2425
contiguous-1.f90
2526
contiguous-2.f90
@@ -51,6 +52,14 @@ file(GLOB UNIMPLEMENTED_FILES CONFIGURE_DEPENDS
5152
pr103390-7.f90
5253
pr103390-8.f90
5354
pr103390-9.f90
55+
56+
# unimplemented: support for polymorphic types
57+
c407a-1.f90
58+
c407b-1.f90
59+
60+
# unimplemented: procedure pointer arguments
61+
removed-restrictions-2.f90
62+
removed-restrictions-4.f90
5463
)
5564

5665
# These tests are skipped because they trigger internal compiler errors.
@@ -127,5 +136,12 @@ file(GLOB SKIPPED_FILES CONFIGURE_DEPENDS
127136
section-1p.f90
128137
)
129138

130-
# There are currently no failing files.
131-
set(FAILING_FILES "")
139+
# These tests fail when they are expected to pass.
140+
file(GLOB FAILING_FILES CONFIGURE_DEPENDS
141+
# These files are expected to compile, but fail to do so.
142+
c535b-1.f90
143+
144+
# These files are expected to fail to compile, but succeed instead.
145+
c516.f90
146+
c524a.f90
147+
)

Fortran/gfortran/regression/coarray/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@
99
set(TESTS)
1010
gfortran_populate_tests(TESTS)
1111
gfortran_add_execute_tests_from("${TESTS}")
12-
# TODO: Enable the "compile" tests.
13-
# gfortran_add_compile_tests_from("${TESTS}")
12+
gfortran_add_compile_tests_from("${TESTS}")

Fortran/gfortran/regression/coarray/DisabledFiles.cmake

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ set(UNSUPPORTED_FILES "")
1212
# These tests trigger "not yet implemented" assertions in flang.
1313
file(GLOB UNIMPLEMENTED_FILES CONFIGURE_DEPENDS
1414
# unimplemented: support for polymorphic types
15+
alloc_comp_2.f90
1516
poly_run_3.f90
1617

1718
# unimplemented: coarray allocation
1819
allocate_errgmsg.f90
20+
array_temporary.f90
1921
get_array.f90
2022
lock_2.f90
2123
move_alloc_1.f90
@@ -28,13 +30,15 @@ file(GLOB UNIMPLEMENTED_FILES CONFIGURE_DEPENDS
2830

2931
# unimplemented: coarray in procedure interface
3032
dummy_1.f90
33+
dummy_2.f90
3134
poly_run_1.f90
3235
pr107441-caf.f90
3336
ptr_comp_1.f08
3437
ptr_comp_2.f08
3538
scalar_alloc_1.f90
3639

3740
# unimplemented: intrinsic: '[SYM]'
41+
array_temporary-1.f90
3842
coindexed_1.f90
3943
collectives_1.f90
4044
collectives_2.f90
@@ -124,6 +128,24 @@ file(GLOB SKIPPED_FILES CONFIGURE_DEPENDS
124128
# error: '[SYM]' is a non-ALLOCATABLE coarray and must have an explicit
125129
# coshape
126130
poly_run_2.f90
131+
132+
# --------------------------------------------------------------------------
133+
#
134+
# These tests are skipped because they are intended to be additional sources
135+
# for codimension2.f90. Because of the way the test-suite is setup, it
136+
# tries to compile all the files - even those that do not have a do-compile
137+
# directive. These files are intended to be compiled together with
138+
# codimension2.f90 because they use a module that is created by the former.
139+
# If compiled separately, they do not find the module and fail to compile.
140+
codimension_2a.f90
141+
codimension_2b.f90
142+
143+
# --------------------------------------------------------------------------
144+
#
145+
# This is a multi-file test, but cannot find the additional sources
146+
# codimension_2a.f90 and codimension_2b.f90. This is almost certainly a bug
147+
# in the build files in llvm-test-suite/Fortran/gfortran.
148+
codimension_2.f90
127149
)
128150

129151
# These tests fail at runtime when they should pass.

Fortran/gfortran/regression/debug/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@
99
set(TESTS)
1010
gfortran_populate_tests(TESTS)
1111
gfortran_add_execute_tests_from("${TESTS}")
12-
# TODO: Enable the "compile" tests.
13-
# gfortran_add_compile_tests_from("${TESTS}")
12+
gfortran_add_compile_tests_from("${TESTS}")

0 commit comments

Comments
 (0)