f18
f18 copied to clipboard
Check for PURE procedures containing image control statements
Constraint C1159 states that a PURE subprogram shall not contain an image control statement.
This check can be modeled after a similar check for image control statements appearing in DO CONCURRENT statements. The code to imitated is in check-do.cc in the "Post()" function for "parser::ExecutableConstruct".
lib/semantics/check-purity.cc does the check now:
$ cat sync_image_pure.f90 PURE FUNCTION DOUBLE(X) REAL, INTENT(IN) :: X integer :: img, nimgs, i[*], tmp ! implicit sync all img = this_image() nimgs = num_images() i = img ! i is ready to use
if ( img .eq. 1 ) then sync images( nimgs ) ! explicit sync 1 with last img tmp = i[ nimgs ] sync images( nimgs ) ! explicit sync 2 with last img i = tmp end if
if ( img .eq. nimgs ) then sync images( 1 ) ! explicit sync 1 with img 1 tmp = i[ 1 ] sync images( 1 ) ! explicit sync 2 with img 1 i = tmp end if write (,) img, i ! all other images wait here END FUNCTION DOUBLE $F18_HOME/bin/f18 -fdebug-semantics sync_image_pure.f90 sync_image_pure.f90:5:9: error: Procedure referenced in PURE subprogram 'double' must be PURE too img = this_image() ^^^^^^^^^^^^ sync_image_pure.f90:6:9: error: Procedure referenced in PURE subprogram 'double' must be PURE too nimgs = num_images() ^^^^^^^^^^^^ sync_image_pure.f90:10:4: error: An image control statement may not appear in a PURE subprogram sync images( nimgs ) ! explicit sync 1 with last img ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ sync_image_pure.f90:12:4: error: An image control statement may not appear in a PURE subprogram sync images( nimgs ) ! explicit sync 2 with last img ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ sync_image_pure.f90:18:4: error: An image control statement may not appear in a PURE subprogram sync images( 1 ) ! explicit sync 1 with img 1 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ sync_image_pure.f90:20:4: error: An image control statement may not appear in a PURE subprogram sync images( 1 ) ! explicit sync 2 with img 1 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ sync_image_pure.f90:23:2: error: External I/O is not allowed in a PURE subprogram write (,) img, i ^^^^^^^^^^^^^^^^^^ f18: semantic errors in sync_image_pure.f90
This issue can be closed.
@kiranktp Have you added this as a test for f18? If not, would you please?
Not yet. I will add this and few more test cases.