Skip to content

Commit 11f89f9

Browse files
committed
[Fortran/gfortran] Correctly handle "shouldfail" tests
Correctly handle the DejaGNU shouldfail annotation which asserts that the test is expected to fail at runtime. Disable tests that now fail. These may be actual bugs in the runtime or a case of flang behaving differently from gfortran and will need to be investigated.
1 parent 35d97bd commit 11f89f9

File tree

2 files changed

+80
-27
lines changed

2 files changed

+80
-27
lines changed

Fortran/gfortran/CMakeLists.txt

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ set(FLANG_ERRORING_FFLAGS
6868
-fcheck-array-temporaries
6969
-fcheck=bounds
7070
-fcheck=do
71+
-fcheck=mem
7172
-fcheck=recursion
7273
-fcoarray=lib
7374
-fcray-pointer
@@ -530,16 +531,23 @@ endfunction()
530531
# Setup an "execute" test. In the case of multi-file tests, MAIN will be the
531532
# main file. For multi-file tests, OTHERS will be the remaining files needed by
532533
# the test. FFLAGS are additional compiler flags needed by the test. LDFLAGS
533-
# are the other linker flags needed by the test.
534-
function(gfortran_add_execute_test main others fflags ldflags)
534+
# are the other linker flags needed by the test. If EXPECT_ERROR evaluates to
535+
# true, the test is expected to fail.
536+
function(gfortran_add_execute_test expect_error main others fflags ldflags)
535537
# PREFIX_EXECUTE will have been defined in the subdirectory from which this
536538
# function is called.
537539
gfortran_unique_target_name("${PREFIX_EXECUTE}" "${main}" target)
538540
gfortran_make_working_dir("${target}" working_dir)
539541
get_filename_component(working_dir_name "${working_dir}" NAME)
540542

541543
llvm_test_executable_no_test(${target} ${main} ${others})
542-
llvm_test_run(WORKDIR "%S/${working_dir_name}")
544+
if (expect_error)
545+
llvm_test_run(
546+
EXECUTABLE "%b/not --crash %S/${target}"
547+
WORKDIR "%S/${working_dir_name}")
548+
else ()
549+
llvm_test_run(WORKDIR "%S/${working_dir_name}")
550+
endif ()
543551
llvm_add_test_for_target(${target})
544552

545553
target_include_directories(${target}
@@ -576,6 +584,9 @@ function(gfortran_add_execute_tests_from tests)
576584
cmake_parse_arguments(GFORTRAN "" "" "FFLAGS;LDFLAGS" ${ARGN})
577585

578586
foreach(file ${tests})
587+
# Whether this test is expected to pass or fail.
588+
set(expect_error OFF)
589+
579590
# The file containing the "run" directive will be the main file.
580591
set(main "")
581592

@@ -611,13 +622,15 @@ function(gfortran_add_execute_tests_from tests)
611622
separate_arguments(file_fflags UNIX_COMMAND ${CMAKE_MATCH_2})
612623
list(REMOVE_ITEM file_fflags ${FLANG_ERRORING_FFLAGS})
613624
list(APPEND fflags ${file_fflags})
625+
elseif (line MATCHES "[{][ ]*dg-shouldfail[ ]+(.*)[}]")
626+
set(expect_error ON)
614627
endif()
615628
endforeach()
616629

617630
# Since any dependent files could also be processed by this function, there
618631
# is no guarantee that main will have been set.
619632
if (main)
620-
gfortran_add_execute_test(${main} "${others}" "${fflags}" "${ldflags}")
633+
gfortran_add_execute_test(${expect_error} ${main} "${others}" "${fflags}" "${ldflags}")
621634
endif()
622635
endforeach()
623636
endfunction()
@@ -632,7 +645,7 @@ function(gfortran_add_execute_tests tests)
632645
list(APPEND ldflags ${GFORTRAN_LDFLAGS})
633646

634647
foreach(file ${tests})
635-
gfortran_add_execute_test(${file} "" "${fflags}" "${ldflags}")
648+
gfortran_add_execute_test(OFF ${file} "" "${fflags}" "${ldflags}")
636649
endforeach()
637650
endfunction()
638651

Fortran/gfortran/regression/DisabledFiles.cmake

Lines changed: 62 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ file(GLOB UNIMPLEMENTED_FILES CONFIGURE_DEPENDS
316316
allocate_with_source_14.f03
317317
allocate_with_source_17.f03
318318
allocate_with_source_21.f03
319+
allocate_with_source_22.f03
320+
allocate_with_source_23.f03
319321
allocate_with_source_25.f90
320322
allocate_with_source_8.f08
321323
associate_18.f08
@@ -534,6 +536,7 @@ file(GLOB UNIMPLEMENTED_FILES CONFIGURE_DEPENDS
534536
proc_ptr_comp_50.f90
535537
proc_ptr_comp_pass_3.f90
536538
proc_ptr_comp_pass_6.f90
539+
ptr_func_assign_1.f08
537540
ptr_func_assign_2.f08
538541
ptr_func_assign_3.f08
539542
realloc_on_assign_20.f90
@@ -1858,17 +1861,41 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
18581861
# require further analysis
18591862
Wall.f90 # no warning for missing & on continuation line in char constant
18601863
Wno-all.f90 # no warning for missing & on continuation line in char constant
1864+
allocate_error_1.f90
1865+
# flang throws a runtime error: "mismatching element counts in array
1866+
# assignment", but gfortran does not for associate_32.f03
1867+
associate_32.f03
18611868
auto_save_2.f90 # requires -fno-automatic -finit-local-zero
18621869
bessel_7.f90 # unclear
1870+
bounds_check_10.f90
1871+
bounds_check_7.f90
1872+
bounds_check_array_ctor_1.f90
1873+
bounds_check_array_ctor_2.f90
1874+
bounds_check_array_ctor_6.f90
1875+
bounds_check_array_ctor_7.f90
1876+
bounds_check_array_ctor_8.f90
1877+
bounds_check_fail_4.f90
1878+
bounds_check_strlen_1.f90
1879+
bounds_check_strlen_2.f90
1880+
bounds_check_strlen_3.f90
1881+
bounds_check_strlen_4.f90
1882+
bounds_check_strlen_5.f90
1883+
bounds_check_strlen_7.f90
1884+
char_bounds_check_fail_1.f90
1885+
char_pointer_assign_4.f90
1886+
char_pointer_assign_5.f90
18631887
check_bits_1.f90 # requires -fcheck=bits to catch ISHFTC runtime error
18641888
check_bits_2.f90 # requires -fcheck=bits to catch ISHFTC runtime error
18651889
cr_lf.f90
1890+
cshift_bounds_2.f90
18661891
cshift_bounds_3.f90
18671892
cshift_bounds_4.f90
18681893
cshift_large_1.f90
18691894
data_char_1.f90
18701895
data_char_3.f90
18711896
deallocate_alloc_opt_3.f90
1897+
deallocate_error_1.f90
1898+
deallocate_error_2.f90
18721899
deallocate_stat_2.f90
18731900
deallocate_stat.f90
18741901
dependency_45.f90
@@ -1877,9 +1904,15 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
18771904
dim_sum_3.f90
18781905
direct_io_7.f90
18791906
do_check_1.f90
1907+
do_check_11.f90
1908+
do_check_12.f90
1909+
do_check_2.f90
1910+
do_check_3.f90
1911+
do_check_4.f90
18801912
dollar_edit_descriptor_4.f
18811913
elemental_dependency_1.f90
18821914
endfile_3.f90
1915+
endfile_4.f90
18831916
eoshift_bounds_1.f90
18841917
eoshift_large_1.f90
18851918
error_format.f90
@@ -1891,6 +1924,7 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
18911924
fmt_f_default_field_width_1.f90
18921925
fmt_f_default_field_width_2.f90
18931926
fmt_g0_1.f08
1927+
fmt_g0_2.f08
18941928
fmt_g_default_field_width_1.f90
18951929
fmt_g_default_field_width_2.f90
18961930
fmt_g.f
@@ -1910,7 +1944,12 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
19101944
init_flag_6.f90
19111945
init_flag_7.f90
19121946
init_flag_9.f90
1947+
# flang throws a runtime error: "mismatching element counts in array
1948+
# assignment", but gfortran does not for inline_matmul_1.f90
1949+
inline_matmul_1.f90
19131950
inline_matmul_15.f90
1951+
inline_sum_bounds_check_1.f90
1952+
inline_sum_bounds_check_2.f90
19141953
inquire_13.f90
19151954
inquire_15.f90
19161955
inquire_5.f90
@@ -1924,7 +1963,10 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
19241963
internal_write_1.f90
19251964
intrinsic_std_4.f90
19261965
io_err_1.f90
1966+
io_real_boz2.f90
19271967
io_real_boz_3.f90
1968+
io_real_boz_4.f90
1969+
io_real_boz_5.f90
19281970
io_real_boz.f90
19291971
iostat_4.f90
19301972
iostat_5.f90
@@ -1936,10 +1978,16 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
19361978
literal_character_constant_1_z.F
19371979
masklr_2.F90
19381980
matmul_5.f90
1981+
matmul_bounds_10.f90
19391982
matmul_bounds_11.f90
19401983
matmul_bounds_13.f90
19411984
matmul_bounds_15.f
19421985
matmul_bounds_16.f
1986+
matmul_bounds_2.f90
1987+
matmul_bounds_3.f90
1988+
matmul_bounds_4.f90
1989+
matmul_bounds_5.f90
1990+
matmul_bounds_8.f90
19431991
matmul_bounds_7.f90
19441992
matmul_bounds_9.f90
19451993
maxloc_2.f90
@@ -1949,6 +1997,7 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
19491997
maxlocval_2.f90
19501998
maxlocval_4.f90
19511999
merge_bits_2.F90
2000+
merge_char_3.f90
19522001
minloc_1.f90
19532002
minlocval_1.f90
19542003
minlocval_4.f90
@@ -1993,6 +2042,7 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
19932042
negative_unit.f
19942043
negative_unit_int8.f
19952044
no_range_check_1.f90
2045+
no_unit_error_1.f90
19962046
norm2_1.f90
19972047
nosigned_zero_2.f90
19982048
open_access_append_2.f90
@@ -2005,6 +2055,8 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
20052055
pad_source_4.f
20062056
pad_source_5.f
20072057
pointer_check_6.f90
2058+
pointer_check_10.f90
2059+
pointer_remapping_6.f08
20082060
pr12884.f
20092061
pr17285.f90
20102062
pr17286.f90
@@ -2019,6 +2071,11 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
20192071
pr96436_3.f90
20202072
pr96436_4.f90
20212073
pr96436_5.f90
2074+
pr96436_6.f90
2075+
pr96436_7.f90
2076+
pr96436_8.f90
2077+
pr96436_9.f90
2078+
pr96436_10.f90
20222079
promotion_3.f90
20232080
promotion_4.f90
20242081
promotion.f90
@@ -2050,7 +2107,10 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
20502107
real8-4.f90
20512108
real_const_3.f90
20522109
realloc_on_assign_11.f90
2110+
recursive_check_11.f90
2111+
recursive_check_13.f90
20532112
recursive_check_7.f90
2113+
recursive_check_9.f90
20542114
repeat_1.f90
20552115
reshape_order_1.f90
20562116
reshape_order_2.f90
@@ -2065,10 +2125,12 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
20652125
streamio_17.f90
20662126
streamio_4.f90
20672127
system_clock_3.f08
2128+
transpose_2.f90
20682129
unf_io_convert_4.f90
20692130
unf_read_corrupted_1.f90
20702131
unf_short_record_1.f90
20712132
unformatted_subrecord_1.f90
2133+
unpack_bounds_1.f90
20722134
unpack_bounds_2.f90
20732135
unpack_bounds_3.f90
20742136
utf8_1.f03
@@ -2689,28 +2751,6 @@ file(GLOB FAILING_FILES CONFIGURE_DEPENDS
26892751
openacc-define-3.f90
26902752
openmp-define-3.f90
26912753

2692-
# Tests looking for runtime errors (e.g., bound checks). Correctly
2693-
# caught by flang runtime when it is used for array assignments.
2694-
allocate_error_6.f90
2695-
allocate_with_source_22.f03
2696-
allocate_with_source_23.f03
2697-
all_bounds_1.f90
2698-
associate_32.f03
2699-
bounds_check_12.f90
2700-
bounds_check_array_ctor_4.f90
2701-
bounds_check_fail_3.f90
2702-
inline_matmul_1.f90
2703-
maxloc_bounds_1.f90
2704-
maxloc_bounds_2.f90
2705-
maxloc_bounds_3.f90
2706-
maxloc_bounds_4.f90
2707-
maxloc_bounds_5.f90
2708-
maxloc_bounds_7.f90
2709-
maxloc_bounds_8.f90
2710-
pack_bounds_1.f90
2711-
ptr_func_assign_1.f08
2712-
spread_bounds_1.f90
2713-
27142754
# Bad test, assigning an 11 elements array to a 12 elements array.
27152755
transfer_array_intrinsic_4.f90
27162756

0 commit comments

Comments
 (0)