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"
7 source $srcdir/common.sh
8 [[ ! -f $src ]] && die
"File not found: $src"
15 cmd
="$FLANG_FC1 $FLANG_FC1_OPTIONS $src"
16 ( cd $temp; $cmd ) > $log 2>&1
17 if [[ $?
-ge 128 ]]; then
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
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; }
31 if diff -U0 $actual $expect > $diffs; then
36 sed -n -e 's/^-\([0-9]\)/actual at \1/p' -e 's/^+\([0-9]\)/expect at \1/p' \