From fccff3f11a7d23bd28b6d92b6ae3f9d33633734a Mon Sep 17 00:00:00 2001 From: Katherine Rasmussen Date: Wed, 19 Oct 2022 10:16:28 -0600 Subject: [PATCH] [flang] Add semantics tests for lock-stmt Add three tests for lock-stmt. The first includes standard-conforming statements, the second includes non-standard-conforming statements because of errors where something unexpected occurs, such as a missing lock-variable, and the third includes non-standard-conforming statements because of semantic errors, such as type or rank mismatches. Reviewed By: rouson Differential Revision: https://reviews.llvm.org/D136628 --- flang/test/Semantics/lockstmt01.f90 | 41 ++++++++++++++++ flang/test/Semantics/lockstmt02.f90 | 55 ++++++++++++++++++++++ flang/test/Semantics/lockstmt03.f90 | 94 +++++++++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+) create mode 100644 flang/test/Semantics/lockstmt01.f90 create mode 100644 flang/test/Semantics/lockstmt02.f90 create mode 100644 flang/test/Semantics/lockstmt03.f90 diff --git a/flang/test/Semantics/lockstmt01.f90 b/flang/test/Semantics/lockstmt01.f90 new file mode 100644 index 0000000..fe2b7e7 --- /dev/null +++ b/flang/test/Semantics/lockstmt01.f90 @@ -0,0 +1,41 @@ +! RUN: %python %S/test_errors.py %s %flang_fc1 +! This test checks for semantic errors in lock statements based on the +! statement specification in section 11.6.10 of the Fortran 2018 standard. + +program test_lock_stmt + use iso_fortran_env, only: lock_type + implicit none + + character(len=128) error_message, msg_array(10) + integer status, stat_array(10) + logical bool, bool_array, coindexed_logical[*] + type(lock_type) :: lock_var[*] + + !___ standard-conforming statements ___ + + lock(lock_var) + lock(lock_var[1]) + lock(lock_var[this_image() + 1]) + lock(lock_var, acquired_lock=bool) + lock(lock_var, acquired_lock=bool_array(1)) + lock(lock_var, acquired_lock=coindexed_logical[1]) + lock(lock_var, stat=status) + lock(lock_var, stat=stat_array(1)) + lock(lock_var, errmsg=error_message) + lock(lock_var, errmsg=msg_array(1)) + + lock(lock_var, stat=status, errmsg=error_message) + lock(lock_var, errmsg=error_message, stat=status) + lock(lock_var, acquired_lock=bool, stat=status) + lock(lock_var, stat=status, acquired_lock=bool) + lock(lock_var, acquired_lock=bool, errmsg=error_message) + lock(lock_var, errmsg=error_message, acquired_lock=bool) + + lock(lock_var, acquired_lock=bool, stat=status, errmsg=error_message) + lock(lock_var, acquired_lock=bool, errmsg=error_message, stat=status) + lock(lock_var, stat=status, acquired_lock=bool, errmsg=error_message) + lock(lock_var, stat=status, errmsg=error_message, acquired_lock=bool) + lock(lock_var, errmsg=error_message, acquired_lock=bool, stat=status) + lock(lock_var, errmsg=error_message, stat=status, acquired_lock=bool) + +end program test_lock_stmt diff --git a/flang/test/Semantics/lockstmt02.f90 b/flang/test/Semantics/lockstmt02.f90 new file mode 100644 index 0000000..0cd7bd3 --- /dev/null +++ b/flang/test/Semantics/lockstmt02.f90 @@ -0,0 +1,55 @@ +! RUN: %python %S/test_errors.py %s %flang_fc1 +! This test checks for semantic errors in lock statements based on the +! statement specification in section 11.6.10 of the Fortran 2018 standard. + +program test_lock_stmt + use iso_fortran_env, only: lock_type + implicit none + + character(len=128) error_message + integer status + logical bool + type(lock_type) :: lock_var[*] + + !___ non-standard-conforming statements ___ + +! missing required lock-variable + + !ERROR: expected '(' + lock + + !ERROR: expected '=' + lock() + + !ERROR: expected ')' + lock(acquired_lock=bool) + + !ERROR: expected ')' + lock(stat=status) + + !ERROR: expected ')' + lock(errmsg=error_message) + +! specifiers in lock-stat-list are not variables + + !ERROR: expected ')' + lock(lock_var, acquired_lock=.true.) + + !ERROR: expected ')' + lock(lock_var, stat=1) + + !ERROR: expected ')' + lock(lock_var, errmsg='c') + +! specifier typos + + !ERROR: expected ')' + lock(lock_var, acquiredlock=bool, stat=status, errmsg=error_message) + + !ERROR: expected ')' + lock(lock_var, acquired_lock=bool, status=status, errmsg=error_message) + + !ERROR: expected ')' + lock(lock_var, acquired_lock=bool, stat=status, errormsg=error_message) + +end program test_lock_stmt diff --git a/flang/test/Semantics/lockstmt03.f90 b/flang/test/Semantics/lockstmt03.f90 new file mode 100644 index 0000000..8079bc5 --- /dev/null +++ b/flang/test/Semantics/lockstmt03.f90 @@ -0,0 +1,94 @@ +! RUN: %python %S/test_errors.py %s %flang_fc1 +! XFAIL: * +! This test checks for semantic errors in lock statements based on the +! statement specification in section 11.6.10 of the Fortran 2018 standard. + +program test_lock_stmt + use iso_fortran_env, only: lock_type, event_type + implicit none + + character(len=128) error_message, msg_array(10), coindexed_msg[*], repeated_msg + integer status, stat_array(10), coindexed_int[*], non_bool, repeated_stat + logical non_integer, bool, bool_array(10), non_char, coindexed_logical[*], repeated_bool + type(lock_type) :: lock_var[*], lock_array(10)[*], non_coarray_lock + type(event_type) :: not_lock_var[*] + + !___ non-standard-conforming statements ___ + +! type mismatches + + !ERROR: to be determined + lock(not_lock_var) + + !ERROR: Must have LOGICAL type, but is INTEGER(4) + lock(lock_var, acquired_lock=non_bool) + + !ERROR: Must have INTEGER type, but is LOGICAL(4) + lock(lock_var, stat=non_integer) + + !ERROR: Must have CHARACTER type, but is LOGICAL(4) + lock(lock_var, errmsg=non_char) + +! rank mismatches + + !ERROR: Must be a scalar value, but is a rank-1 array + lock(lock_array) + + !ERROR: Must be a scalar value, but is a rank-1 array + lock(lock_var, acquired_lock=bool_array) + + !ERROR: Must be a scalar value, but is a rank-1 array + lock(lock_var, stat=stat_array) + + !ERROR: Must be a scalar value, but is a rank-1 array + lock(lock_var, errmsg=msg_array) + +! corank mismatch + + !ERROR: to be determined + lock(non_coarray_lock) + +! C1173 - stat-variable and errmsg-variable shall not be a coindexed object + + !ERROR: to be determined + lock(lock_var, stat=coindexed_int[1]) + + !ERROR: to be determined + lock(lock_var, errmsg=coindexed_msg[1]) + + !ERROR: to be determined + lock(lock_var, acquired_lock=coindexed_logical[1], stat=coindexed_int[1], errmsg=coindexed_msg[1]) + +! C1181 - No specifier shall appear more than once in a given lock-stat-list + + !ERROR: to be determined + lock(lock_var, acquired_lock=bool, acquired_lock=repeated_bool) + + !ERROR: to be determined + lock(lock_var, stat=status, stat=repeated_stat) + + !ERROR: to be determined + lock(lock_var, errmsg=error_message, errmsg=repeated_msg) + + !ERROR: to be determined + lock(lock_var, acquired_lock=bool, stat=status, errmsg=error_message, acquired_lock=repeated_bool) + + !ERROR: to be determined + lock(lock_var, acquired_lock=bool, stat=status, errmsg=error_message, stat=repeated_stat) + + !ERROR: to be determined + lock(lock_var, acquired_lock=bool, stat=status, errmsg=error_message, errmsg=repeated_msg) + + !ERROR: to be determined + lock(lock_var, acquired_lock=bool, stat=status, errmsg=error_message, acquired_lock=repeated_bool, stat=repeated_stat) + + !ERROR: to be determined + lock(lock_var, acquired_lock=bool, stat=status, errmsg=error_message, acquired_lock=repeated_bool, errmsg=repeated_msg) + + !ERROR: to be determined + lock(lock_var, acquired_lock=bool, stat=status, errmsg=error_message, stat=repeated_stat, errmsg=repeated_msg) + + !ERROR: to be determined + lock(lock_var, acquired_lock=bool, stat=status, errmsg=error_message, acquired_lock=repeated_bool, stat=repeated_stat, errmsg=repeated_msg) + +end program test_lock_stmt -- 2.7.4