111 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! This test checks for semantic errors in lock statements based on the3! statement specification in section 11.6.10 of the Fortran 2018 standard.4 5program test_lock_stmt6 use iso_fortran_env, only: lock_type, event_type7 implicit none8 9 character(len=128) error_message, msg_array(10), coindexed_msg[*], repeated_msg10 integer status, stat_array(10), coindexed_int[*], non_bool, repeated_stat11 logical non_integer, bool, bool_array(10), non_char, coindexed_logical[*], repeated_bool12 type(lock_type) :: lock_var[*], lock_array(10)[*]13 !ERROR: Variable 'non_coarray_lock' with EVENT_TYPE or LOCK_TYPE must be a coarray14 type(lock_type) :: non_coarray_lock15 type(event_type) :: not_lock_var[*]16 17 !___ non-standard-conforming statements ___18 19! type mismatches20 21 !ERROR: Lock variable must have type LOCK_TYPE from ISO_FORTRAN_ENV22 lock(not_lock_var)23 24 !ERROR: Must have LOGICAL type, but is INTEGER(4)25 lock(lock_var, acquired_lock=non_bool)26 27 !ERROR: Must have INTEGER type, but is LOGICAL(4)28 lock(lock_var, stat=non_integer)29 30 !ERROR: Must have CHARACTER type, but is LOGICAL(4)31 lock(lock_var, errmsg=non_char)32 33! rank mismatches34 35 !ERROR: Must be a scalar value, but is a rank-1 array36 lock(lock_array)37 38 !ERROR: Must be a scalar value, but is a rank-1 array39 lock(lock_var, acquired_lock=bool_array)40 41 !ERROR: Must be a scalar value, but is a rank-1 array42 lock(lock_var, stat=stat_array)43 44 !ERROR: Must be a scalar value, but is a rank-1 array45 lock(lock_var, errmsg=msg_array)46 47! corank mismatch48 49 lock(non_coarray_lock) ! caught above50 51! C1173 - stat-variable and errmsg-variable shall not be a coindexed object52 53 !ERROR: The stat-variable or errmsg-variable in a sync-stat-list may not be a coindexed object54 lock(lock_var, stat=coindexed_int[1])55 56 !ERROR: The stat-variable or errmsg-variable in a sync-stat-list may not be a coindexed object57 lock(lock_var, errmsg=coindexed_msg[1])58 59 !ERROR: The stat-variable or errmsg-variable in a sync-stat-list may not be a coindexed object60 !ERROR: The stat-variable or errmsg-variable in a sync-stat-list may not be a coindexed object61 lock(lock_var, acquired_lock=coindexed_logical[1], stat=coindexed_int[1], errmsg=coindexed_msg[1])62 63! C1181 - No specifier shall appear more than once in a given lock-stat-list64 65 !ERROR: Multiple ACQUIRED_LOCK specifiers66 lock(lock_var, acquired_lock=bool, acquired_lock=repeated_bool)67 68 !ERROR: The stat-variable in a sync-stat-list may not be repeated69 lock(lock_var, stat=status, stat=repeated_stat)70 71 !ERROR: The errmsg-variable in a sync-stat-list may not be repeated72 lock(lock_var, errmsg=error_message, errmsg=repeated_msg)73 74 !ERROR: Multiple ACQUIRED_LOCK specifiers75 lock(lock_var, acquired_lock=bool, stat=status, errmsg=error_message, acquired_lock=repeated_bool)76 77 !ERROR: The stat-variable in a sync-stat-list may not be repeated78 lock(lock_var, acquired_lock=bool, stat=status, errmsg=error_message, stat=repeated_stat)79 80 !ERROR: The errmsg-variable in a sync-stat-list may not be repeated81 lock(lock_var, acquired_lock=bool, stat=status, errmsg=error_message, errmsg=repeated_msg)82 83 !ERROR: The stat-variable in a sync-stat-list may not be repeated84 !ERROR: Multiple ACQUIRED_LOCK specifiers85 lock(lock_var, acquired_lock=bool, stat=status, errmsg=error_message, acquired_lock=repeated_bool, stat=repeated_stat)86 87 !ERROR: The errmsg-variable in a sync-stat-list may not be repeated88 !ERROR: Multiple ACQUIRED_LOCK specifiers89 lock(lock_var, acquired_lock=bool, stat=status, errmsg=error_message, acquired_lock=repeated_bool, errmsg=repeated_msg)90 91 !ERROR: The stat-variable in a sync-stat-list may not be repeated92 !ERROR: The errmsg-variable in a sync-stat-list may not be repeated93 lock(lock_var, acquired_lock=bool, stat=status, errmsg=error_message, stat=repeated_stat, errmsg=repeated_msg)94 95 !ERROR: The stat-variable in a sync-stat-list may not be repeated96 !ERROR: The errmsg-variable in a sync-stat-list may not be repeated97 !ERROR: Multiple ACQUIRED_LOCK specifiers98 lock(lock_var, acquired_lock=bool, stat=status, errmsg=error_message, acquired_lock=repeated_bool, stat=repeated_stat, errmsg=repeated_msg)99 100 contains101 subroutine lockit(x)102 type(lock_type), intent(in) :: x[*]103 !ERROR: Lock variable is not definable104 !BECAUSE: 'x' is an INTENT(IN) dummy argument105 lock(x)106 !ERROR: Lock variable is not definable107 !BECAUSE: 'x' is an INTENT(IN) dummy argument108 unlock(x)109 end110end program test_lock_stmt111