2021-04-12 20:27:49 +08:00
|
|
|
! RUN: %S/test_errors.sh %s %t %flang_fc1
|
2019-10-30 03:46:25 +08:00
|
|
|
! Test 8.5.18 constraints on the VALUE attribute
|
|
|
|
|
|
|
|
module m
|
|
|
|
type :: hasCoarray
|
[flang] New implementation for checks for constraints C741 through C750
Summary:
Most of these checks were already implemented, and I just added references to
them to the code and tests. Also, much of this code was already
reviewed in the old flang/f18 GitHub repository, but I didn't get to
merge it before we switched repositories.
I implemented the check for C747 to not allow coarray components in derived
types that are of type C_PTR, C_FUNPTR, or type TEAM_TYPE.
I implemented the check for C748 that requires a data component whose type has
a coarray ultimate component to be a nonpointer, nonallocatable scalar and not
be a coarray.
I implemented the check for C750 that adds additional restrictions to the
bounds expressions of a derived type component that's an array.
These bounds expressions are sepcification expressions as defined in
10.1.11. There was already code in lib/Evaluate/check-expression.cpp to
check semantics for specification expressions, but it did not check for
the extra requirements of C750.
C750 prohibits specification functions, the intrinsic functions
ALLOCATED, ASSOCIATED, EXTENDS_TYPE_OF, PRESENT, and SAME_TYPE_AS. It
also requires every specification inquiry reference to be a constant
expression, and requires that the value of the bound not depend on the
value of a variable.
To implement these additional checks, I added code to the intrinsic proc
table to get the intrinsic class of a procedure. I also added an
enumeration to distinguish between specification expressions for
derived type component bounds versus for type parameters. I then
changed the code to pass an enumeration value to
"CheckSpecificationExpr()" to indicate that the expression was a bounds
expression and used this value to determine whether to emit an error
message when violations of C750 are found.
I changed the implementation of IsPureProcedure() to handle statement
functions and changed some references in the code that tested for the
PURE attribute to call IsPureProcedure().
I also fixed some unrelated tests that got new errors when I implemented these
new checks.
Reviewers: tskeith, DavidTruby, sscalpone
Subscribers: jfb, llvm-commits
Tags: #llvm, #flang
Differential Revision: https://reviews.llvm.org/D79263
2020-05-02 04:00:28 +08:00
|
|
|
real, allocatable :: coarray[:]
|
2019-10-30 03:46:25 +08:00
|
|
|
end type
|
|
|
|
contains
|
|
|
|
!ERROR: VALUE attribute may apply only to a dummy data object
|
|
|
|
subroutine C863(notData,assumedSize,coarray,coarrayComponent)
|
|
|
|
external :: notData
|
|
|
|
!ERROR: VALUE attribute may apply only to a dummy argument
|
|
|
|
real, value :: notADummy
|
|
|
|
value :: notData
|
|
|
|
!ERROR: VALUE attribute may not apply to an assumed-size array
|
|
|
|
real, value :: assumedSize(10,*)
|
|
|
|
!ERROR: VALUE attribute may not apply to a coarray
|
|
|
|
real, value :: coarray[*]
|
|
|
|
!ERROR: VALUE attribute may not apply to a type with a coarray ultimate component
|
|
|
|
type(hasCoarray), value :: coarrayComponent
|
|
|
|
end subroutine
|
|
|
|
subroutine C864(allocatable, inout, out, pointer, volatile)
|
|
|
|
!ERROR: VALUE attribute may not apply to an ALLOCATABLE
|
|
|
|
real, value, allocatable :: allocatable
|
|
|
|
!ERROR: VALUE attribute may not apply to an INTENT(IN OUT) argument
|
|
|
|
real, value, intent(in out) :: inout
|
|
|
|
!ERROR: VALUE attribute may not apply to an INTENT(OUT) argument
|
|
|
|
real, value, intent(out) :: out
|
|
|
|
!ERROR: VALUE attribute may not apply to a POINTER
|
|
|
|
real, value, pointer :: pointer
|
|
|
|
!ERROR: VALUE attribute may not apply to a VOLATILE
|
|
|
|
real, value, volatile :: volatile
|
|
|
|
end subroutine
|
|
|
|
subroutine C865(optional) bind(c)
|
|
|
|
!ERROR: VALUE attribute may not apply to an OPTIONAL in a BIND(C) procedure
|
|
|
|
real, value, optional :: optional
|
|
|
|
end subroutine
|
|
|
|
end module
|