llvm-project/flang/lib/Semantics
Pete Steinfeld 8d0c3c05f2 [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-05 09:37:39 -07:00
..
CMakeLists.txt [flang] Compute sizes and offsets for symbols 2020-04-23 14:54:34 -07:00
assignment.cpp [flang] Add message formatting for std::int64_t 2020-04-03 17:28:23 -07:00
assignment.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
attr.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
canonicalize-do.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
canonicalize-do.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
canonicalize-omp.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
canonicalize-omp.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-allocate.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-allocate.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-arithmeticif.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-arithmeticif.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-call.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-call.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-case.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-case.h [flang] Semantics for SELECT CASE 2020-03-27 12:02:11 -07:00
check-coarray.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-coarray.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-data.cpp Rework DATA statement semantics to use typed expressions 2020-04-25 10:29:34 -07:00
check-data.h Rework DATA statement semantics to use typed expressions 2020-04-25 10:29:34 -07:00
check-deallocate.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-deallocate.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-declarations.cpp [flang] New implementation for checks for constraints C741 through C750 2020-05-05 09:37:39 -07:00
check-declarations.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-do-forall.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-do-forall.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-if-stmt.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-if-stmt.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-io.cpp [flang] Add missing check for unresolved name 2020-04-23 07:00:38 -07:00
check-io.h [flang] Process names in ASSIGN and assigned GOTO 2020-04-03 14:58:07 -07:00
check-namelist.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-namelist.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-nullify.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-nullify.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-omp-structure.cpp [flang][NFC] Fix gcc 9 warning in omp combined construct checks. 2020-04-27 17:59:06 +01:00
check-omp-structure.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-purity.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-purity.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-return.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-return.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-stop.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
check-stop.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
compute-offsets.cpp [flang] Compute sizes and offsets for symbols 2020-04-23 14:54:34 -07:00
compute-offsets.h [flang] Compute sizes and offsets for symbols 2020-04-23 14:54:34 -07:00
expression.cpp [flang] New implementation for checks for constraints C741 through C750 2020-05-05 09:37:39 -07:00
mod-file.cpp [flang] Compute sizes and offsets for symbols 2020-04-23 14:54:34 -07:00
mod-file.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
pointer-assignment.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
pointer-assignment.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
program-tree.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
program-tree.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
resolve-labels.cpp [flang] Process names in ASSIGN and assigned GOTO 2020-04-03 14:58:07 -07:00
resolve-labels.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
resolve-names-utils.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
resolve-names-utils.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
resolve-names.cpp [flang] New implementation for checks for constraints C741 through C750 2020-05-05 09:37:39 -07:00
resolve-names.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
rewrite-parse-tree.cpp [flang] Process names in ASSIGN and assigned GOTO 2020-04-03 14:58:07 -07:00
rewrite-parse-tree.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
scope.cpp [flang] Compute sizes and offsets for symbols 2020-04-23 14:54:34 -07:00
semantics.cpp [flang] Compute sizes and offsets for symbols 2020-04-23 14:54:34 -07:00
symbol.cpp [flang] Compute sizes and offsets for symbols 2020-04-23 14:54:34 -07:00
tools.cpp [flang] New implementation for checks for constraints C741 through C750 2020-05-05 09:37:39 -07:00
type.cpp [flang] Fixed a crash 2020-05-04 07:54:23 -07:00
unparse-with-symbols.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00