diff --git a/flang/test/semantics/CMakeLists.txt b/flang/test/semantics/CMakeLists.txt index c6794e766e5fd..43aa68deb879a 100644 --- a/flang/test/semantics/CMakeLists.txt +++ b/flang/test/semantics/CMakeLists.txt @@ -140,6 +140,9 @@ set(ERROR_TESTS # omp-nested01.f90 equivalence01.f90 init01.f90 + if_arith01.f90 + if_construct01.f90 + if_stmt01.f90 ) # These test files have expected symbols in the source @@ -211,40 +214,24 @@ set(FORALL_TESTS forall*.[Ff]90 ) -set(IF_TESTS - if_arith01.f90 - if_construct01.f90 - if_stmt01.f90 -) +set(F18 $) foreach(test ${ERROR_TESTS}) - add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_errors.sh ${test}) + add_test(NAME ${test} + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_errors.sh ${test} ${F18}) endforeach() foreach(test ${SYMBOL_TESTS}) - add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_symbols.sh ${test}) + add_test(NAME ${test} + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_symbols.sh ${test} ${F18}) endforeach() foreach(test ${MODFILE_TESTS}) - add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_modfile.sh ${test}) -endforeach() - -foreach(test ${LABEL_TESTS}) - add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_any.sh ${test}) -endforeach() - -foreach(test ${CANONDO_TESTS}) - add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_any.sh ${test}) -endforeach() - -foreach(test ${DOCONCURRENT_TESTS}) - add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_any.sh ${test}) -endforeach() - -foreach(test ${FORALL_TESTS}) - add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_any.sh ${test}) + add_test(NAME ${test} + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_modfile.sh ${test} ${F18}) endforeach() -foreach(test ${IF_TESTS}) - add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_any.sh ${test}) +foreach(test ${LABEL_TESTS} ${CANONDO_TESTS} ${DOCONCURRENT_TESTS} ${FORALL_TESTS}) + add_test(NAME ${test} + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_any.sh ${test} ${F18}) endforeach() diff --git a/flang/test/semantics/allocate11.f90 b/flang/test/semantics/allocate11.f90 index 0f1de3ee07b51..7fe46aec2bcab 100644 --- a/flang/test/semantics/allocate11.f90 +++ b/flang/test/semantics/allocate11.f90 @@ -90,20 +90,6 @@ subroutine C937(var) allocate(C:: var) end subroutine -module iso_fortran_env - type :: team_type - end type -end module - -module iso_c_binding - type :: c_ptr - integer(kind=8) ptr - end type - type :: c_funptr - integer(kind=8) ptr - end type -end module - !TODO: type extending team_type !? subcomponents !? subroutine C938_C947(var2, ptr, ptr2, fptr, my_team, srca) diff --git a/flang/test/semantics/allocate13.f90 b/flang/test/semantics/allocate13.f90 index d171679e414aa..3c4705c0ce248 100644 --- a/flang/test/semantics/allocate13.f90 +++ b/flang/test/semantics/allocate13.f90 @@ -14,13 +14,6 @@ ! Check for semantic errors in ALLOCATE statements -module iso_fortran_env - type event_type - end type - type lock_type - end type -end module - module not_iso_fortran_env type event_type end type diff --git a/flang/test/semantics/coarrays01.f90 b/flang/test/semantics/coarrays01.f90 index a8d7ea4b27aea..acab8845f462c 100644 --- a/flang/test/semantics/coarrays01.f90 +++ b/flang/test/semantics/coarrays01.f90 @@ -14,12 +14,6 @@ ! Test selector and team-value in CHANGE TEAM statement -! Temporary, until we have real iso_fortran_env -module iso_fortran_env - type :: team_type - end type -end - ! OK subroutine s1 use iso_fortran_env, only: team_type diff --git a/flang/test/semantics/common.sh b/flang/test/semantics/common.sh new file mode 100644 index 0000000000000..5a68dd6fd02b6 --- /dev/null +++ b/flang/test/semantics/common.sh @@ -0,0 +1,39 @@ +# Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Common functionality for test scripts +# Process arguments, expecting source file as 1st; optional path to f18 as 2nd +# Set: $F18 to the path to f18; $temp to an empty temp directory; and $src +# to the full path of the single source argument + +PATH=/usr/bin:/bin + +function die { + echo "$(basename $0): $*" >&2 + exit 1 +} + +case $# in + (1) ;; + (2) F18=$2 ;; + (*) echo "Usage: $(basename $0) []"; exit 1 +esac +[[ -z ${F18+x} ]] && die "Path to f18 must be second argument or in F18 environment variable" +[[ ! -f $F18 ]] && die "f18 executable not found: $F18" +case $1 in + (/*) src=$1 ;; + (*) src=$(dirname $0)/$1 ;; +esac +temp=`mktemp -d ./tmp.XXXXXX` +[[ $KEEP ]] || trap "rm -rf $temp" EXIT diff --git a/flang/test/semantics/resolve50.f90 b/flang/test/semantics/resolve50.f90 index 2331beca9273a..028b937f29195 100644 --- a/flang/test/semantics/resolve50.f90 +++ b/flang/test/semantics/resolve50.f90 @@ -14,11 +14,6 @@ ! Test coarray association in CHANGE TEAM statement -module iso_fortran_env - type :: team_type - end type -end - subroutine s1 use iso_fortran_env type(team_type) :: t diff --git a/flang/test/semantics/test_any.sh b/flang/test/semantics/test_any.sh index e3650dd2b7f32..54c2ebd3a6172 100755 --- a/flang/test/semantics/test_any.sh +++ b/flang/test/semantics/test_any.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. +# Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,9 +17,10 @@ # we get the right symbols in the output, i.e. the output should be # the same as the input, except for the copyright comment. # Change the compiler by setting the F18 environment variable. -PATH=/usr/bin:/bin + srcdir=$(dirname $0) -F18=${F18:=../../tools/f18/bin/f18} +source $srcdir/common.sh + FileCheck=${FileCheck:=internal_check} function internal_check() { @@ -50,11 +51,9 @@ function internal_check() { gr=0 for input in ${srcdir}/$*; do - lr=true CMD=$(cat ${input} | egrep '^[[:space:]]*![[:space:]]*RUN:[[:space:]]*' | sed -e 's/^[[:space:]]*![[:space:]]*RUN:[[:space:]]*//') CMD=$(echo ${CMD} | sed -e "s:%s:${input}:g") - $(eval $CMD) || lr=false - if $lr; then + if $(eval $CMD); then echo "PASS ${input}" else echo "FAIL ${input}" diff --git a/flang/test/semantics/test_errors.sh b/flang/test/semantics/test_errors.sh index f746bfbd23c20..671228301811e 100755 --- a/flang/test/semantics/test_errors.sh +++ b/flang/test/semantics/test_errors.sh @@ -16,22 +16,10 @@ # Compile a source file and check errors against those listed in the file. # Change the compiler by setting the F18 environment variable. -PATH=/usr/bin:/bin +F18_OPTIONS="-fdebug-resolve-names -fparse-only" srcdir=$(dirname $0) -CMD="${F18:-../../../tools/f18/bin/f18} -fdebug-resolve-names -fparse-only" - -if [[ $# != 1 ]]; then - echo "Usage: $0 " - exit 1 -fi -case $1 in -(/*) src=$1 ;; -(*) src=$srcdir/$1 ;; -esac -[[ ! -f $src ]] && echo "File not found: $src" && exit 1 - -temp=`mktemp -d ./tmp.XXXXXX` -[[ $KEEP ]] || trap "rm -rf $temp" EXIT +source $srcdir/common.sh +[[ ! -f $src ]] && die "File not found: $src" log=$temp/log actual=$temp/actual @@ -43,7 +31,8 @@ options=$temp/options sed -n 's/^ *! *OPTIONS: *//p' $src > $options cat $options -cmd="$CMD `cat $options` $src" +include=$(dirname $(dirname $F18))/include +cmd="$F18 $F18_OPTIONS -I$include `cat $options` $src" ( cd $temp; $cmd ) > $log 2>&1 if [[ $? -ge 128 ]]; then cat $log @@ -66,6 +55,5 @@ else < $diffs \ sed -n -e 's/^-\([0-9]\)/actual at \1/p' -e 's/^+\([0-9]\)/expect at \1/p' \ | sort -n -k 2 - echo FAIL - exit 1 + die FAIL fi diff --git a/flang/test/semantics/test_modfile.sh b/flang/test/semantics/test_modfile.sh index df430604c1b42..835faa1724766 100755 --- a/flang/test/semantics/test_modfile.sh +++ b/flang/test/semantics/test_modfile.sh @@ -16,19 +16,10 @@ # Compile a source file and compare generated .mod files against expected. set -e -PATH=/usr/bin:/bin +F18_OPTIONS="-fdebug-resolve-names -fparse-only" srcdir=$(dirname $0) -CMD="${F18:-../../../tools/f18/bin/f18} -fdebug-resolve-names -fparse-only" -if [[ $# != 1 ]]; then - echo "Usage: $0 " - exit 1 -fi -src=$srcdir/$1 +source $srcdir/common.sh -temp=temp-$1 -rm -rf $temp -mkdir $temp -[[ $KEEP ]] || trap "rm -rf $temp" EXIT actual=$temp/actual.mod expect=$temp/expect.mod actual_files=$temp/actual_files @@ -43,7 +34,7 @@ for src in "$@"; do ( cd $temp ls -1 *.mod > prev_files - $CMD $src + $F18 $F18_OPTIONS $src ls -1 *.mod | comm -13 prev_files - ) > $actual_files expected_files=$(sed -n 's/^!Expect: \(.*\)/\1/p' $src | sort) diff --git a/flang/test/semantics/test_symbols.sh b/flang/test/semantics/test_symbols.sh index ad6599e0b14fe..626f571aa8e3a 100755 --- a/flang/test/semantics/test_symbols.sh +++ b/flang/test/semantics/test_symbols.sh @@ -18,22 +18,11 @@ # the same as the input, except for the copyright comment. # Change the compiler by setting the F18 environment variable. -PATH=/usr/bin:/bin +F18_OPTIONS="-funparse-with-symbols" srcdir=$(dirname $0) -CMD="${F18:-../../../tools/f18/bin/f18} -funparse-with-symbols" - -if [[ $# != 1 ]]; then - echo "Usage: $0 " - exit 1 -fi -src=$srcdir/$1 +source $srcdir/common.sh [[ ! -f $src ]] && echo "File not found: $src" && exit 1 -temp=temp-$1 -rm -rf $temp -mkdir $temp -[[ $KEEP ]] || trap "rm -rf $temp" EXIT - src1=$temp/1.f90 src2=$temp/2.f90 src3=$temp/3.f90 @@ -44,7 +33,8 @@ sed -e 's/!\([DR]EF:\)/KEEP \1/' \ -e 's/!.*//' -e 's/ *$//' -e '/^$/d' -e 's/KEEP \([DR]EF:\)/!\1/' \ $src > $src1 egrep -v '^ *!' $src1 > $src2 # strip out meaningful comments -( cd $temp; $CMD $(basename $src2) ) > $src3 # compile, inserting comments for symbols +# compile, inserting comments for symbols: +( cd $temp; $F18 $F18_OPTIONS $(basename $src2) ) > $src3 if diff -w -U999999 $src1 $src3 > $diffs; then echo PASS