[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / test_errors.sh
blob20486b3abebaa6c7ce1a5c38ce0bdf7f98f61035
1 #!/usr/bin/env bash
2 # Compile a source file and check errors against those listed in the file.
3 # Change the compiler by setting the FLANG_FC1 environment variable.
5 FLANG_FC1_OPTIONS="-fsyntax-only"
6 srcdir=$(dirname $0)
7 source $srcdir/common.sh
8 [[ ! -f $src ]] && die "File not found: $src"
10 log=$temp/log
11 actual=$temp/actual
12 expect=$temp/expect
13 diffs=$temp/diffs
15 cmd="$FLANG_FC1 $FLANG_FC1_OPTIONS $src"
16 ( cd $temp; $cmd ) > $log 2>&1
17 if [[ $? -ge 128 ]]; then
18 cat $log
19 exit 1
22 # $actual has errors from the compiler; $expect has them from !ERROR comments in source
23 # Format both as "<line>: <text>" so they can be diffed.
24 sed -n 's=^[^:]*:\([^:]*\):[^:]*: error: =\1: =p' $log > $actual
25 awk '
26 BEGIN { FS = "!ERROR: "; }
27 /^ *!ERROR: / { errors[nerrors++] = $2; next; }
28 { for (i = 0; i < nerrors; ++i) printf "%d: %s\n", NR, errors[i]; nerrors = 0; }
29 ' $src > $expect
31 if diff -U0 $actual $expect > $diffs; then
32 echo PASS
33 else
34 echo "$cmd"
35 < $diffs \
36 sed -n -e 's/^-\([0-9]\)/actual at \1/p' -e 's/^+\([0-9]\)/expect at \1/p' \
37 | sort -n -k 3
38 die FAIL