This is an archive of the discontinued LLVM Phabricator instance.

[flang] New implementation for checks for constraints C741 through C750
ClosedPublic

Authored by PeteSteinfeld on May 1 2020, 2:01 PM.

Details

Summary

Most of this was previously in review in D78160. Since that last review, I
added an enumeration to distinguish between specification expressions for
component bounds and 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.

Here's the information about the overall changes in the previous review:

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. 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 do this, I
added code to the intrinsic proc table to get the intrinsic class of a
procedure.

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.

Diff Detail

Event Timeline

PeteSteinfeld created this revision.May 1 2020, 2:01 PM
Herald added a project: Restricted Project. · View Herald Transcript
PeteSteinfeld added a project: Restricted Project.May 1 2020, 2:07 PM
tskeith accepted this revision.May 4 2020, 7:13 AM
tskeith added inline comments.
flang/include/flang/Evaluate/check-expression.h
55

const is meaningless in const SpecificationExprContext.

This revision is now accepted and ready to land.May 4 2020, 7:13 AM
PeteSteinfeld marked an inline comment as done.May 4 2020, 8:09 AM
PeteSteinfeld added inline comments.
flang/include/flang/Evaluate/check-expression.h
55

Thanks, Tim. I'll remove it.

Response to review comments

Removed an unnecessary "const" as per Tim's recommendation.

This revision was automatically updated to reflect the committed changes.