This is an archive of the discontinued LLVM Phabricator instance.

[flang] Add semantics tests for lock-stmt
ClosedPublic

Authored by ktras on Oct 24 2022, 10:53 AM.

Details

Summary

Add three semantics tests for lock-stmt. The first includes
standard-conforming statements, the second includes
non-standard-conforming statements because of syntax errors,
and the third includes non-standard-conforming statements
because of semantic errors, such as type or rank mismatches.

Diff Detail

Event Timeline

ktras created this revision.Oct 24 2022, 10:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 24 2022, 10:53 AM
Herald added a subscriber: jdoerfert. · View Herald Transcript
ktras requested review of this revision.Oct 24 2022, 10:53 AM
rouson requested changes to this revision.Oct 25 2022, 5:32 PM

In order check constraint C1608 in the Fortran 2018 standard, let's add a check that flang accepts the following with and without the allocatable attribute

  use iso_fortran_env
  type foo
    type(lock_type), allocatable :: bar
  end type
  type(foo) foobar[*]
end

which gfortran rejects when the allocatable attribute is present but the NAG (nagfor) compiler correctly accepts either way.

This revision now requires changes to proceed.Oct 25 2022, 5:32 PM
rouson accepted this revision.Oct 25 2022, 5:52 PM

Have you looked into whether there's a useful way to test constraint C1607, .e.g, with

type(lock_type)=, parameter :: const[*]=0

which seems not so useful because a parameter can't be be a coarray and a lock_type entity must be a coarray, but it's possible there's better way to test the constraint or it's possible the constraint is redundant because of C1608.

This revision is now accepted and ready to land.Oct 25 2022, 5:52 PM

Similarly, have you considered adding a differential to test C1609 and C1610?

This revision was automatically updated to reflect the committed changes.
ktras added a comment.Oct 26 2022, 5:33 PM

@rouson Thanks for the review. I have landed this patch and based on your suggestion, I will work on a separate test and separate differential where I will test the different possibilities for declarations of type lock_type and testing the constraints that you referenced.