Files
clang-p2996/flang/test/Semantics/allocate02.f90
Tim Keith 99aa87a5b5 [flang][NFC] Simplify semantics test scripts
There were several different ways of handling the option to f18 to
find predefined modules:
- test_errors.sh was created by cmake substituting
  FLANG_INTRINSIC_MODULES_DIR into test_errors.sh.in
- some tests used the flang script which has the option built it
- some tests used %f18_with_includes which was replaced by the path
  to f18 plus the -I option
- some included -I../../include/flang in their run command

To make this more consistent, change %f18 to include the
-intrinsic-module-directory option and use it everywhere, including
to replace %flang and %f18_with_includes. This requires changing all
of the invocations of the test scripts to put %f18 at the end so that
it can expand to more than one argument.

This eliminates the need to generate test_errors.sh which means we
don't need flang/test/Semantics/CMakeLists.txt or the %B substitution.
That makes the test_errors.sh command like the others, replacing
%B/test/Semantics/test_errors.sh with %S/test_errors.sh.

Also remove the OPTIONS: functionality as custom options can be included
in the RUN: command. And remove -I/../../include/flang as that is now
always included.

Differential Revision: https://reviews.llvm.org/D79634
2020-05-11 11:49:25 -07:00

50 lines
1.9 KiB
Fortran

! RUN: %S/test_errors.sh %s %t %f18
! Check for semantic errors in ALLOCATE statements
subroutine C943_C944(src, src2)
! C943
! No alloc-opt shall appear more than once in a given alloc-opt-list.
character(50) msg
integer stat, stat2
real src(2:4), src2(2:4)
real mld(2:4), mld2(2:4)
real, allocatable :: x1(:), x2(:), x3(:), x4(:), x5(:), x6(:), x7(:), x8(:), x9(:)
real, allocatable :: y1(:), y2(:), y3(:), y4(:)
real, pointer :: p1, p2
!Nominal cases, no error expected
allocate(x1, source=src)
allocate(x2, mold=mld)
allocate(x3(2:4), stat=stat)
allocate(x4(2:4), stat=stat, errmsg=msg)
allocate(x5(2:4), source=src, stat=stat, errmsg=msg)
!ERROR: STAT may not be duplicated in a ALLOCATE statement
allocate(x6, stat=stat, source=src, stat=stat2)
!ERROR: SOURCE may not be duplicated in a ALLOCATE statement
allocate(x7, source=src, stat=stat, source=src2)
!ERROR: MOLD may not be duplicated in a ALLOCATE statement
allocate(x8, mold=mld, stat=stat, mold=mld)
!ERROR: ERRMSG may not be duplicated in a ALLOCATE statement
allocate(x9, mold=mld, errmsg=msg, stat=stat, errmsg= msg)
! C944
! At most one of source-expr and type-spec must appear.
!Nominal cases already tested in C943 and type-spec tests (e.g C934)
!ERROR: At most one of source-expr and type-spec may appear in a ALLOCATE statement
allocate(real:: y1, source=src)
!ERROR: At most one of source-expr and type-spec may appear in a ALLOCATE statement
allocate(real:: y2, mold=mld)
!ERROR: At most one of source-expr and type-spec may appear in a ALLOCATE statement
allocate(y3, source=src, stat=stat, errmsg=msg, mold=mld)
!ERROR: At most one of source-expr and type-spec may appear in a ALLOCATE statement
!ERROR: At most one of source-expr and type-spec may appear in a ALLOCATE statement
allocate(real:: y4, source=src, stat=stat, errmsg=msg, mold=mld)
end subroutine