# location testcase #1 -*- shell-script -*-

test=location-1

source ./test-utils.sh

cpu_file=${test}.test.cpu
rm -f ${cpu_file}

cat > ${cpu_file} <<EOF
(define-rtl-version 0 9)
(include "${srcdir}/../cpu/simplify.inc")
(include "${srcdir}/testsuite.cpu")

(define-pmacro test-insns (add sub))

(define-pmacro (define-test-insn name)
  (bad-command name)
)

(%for-each (%pmacro (name)
             (%exec (define-test-insn name)))
           test-insns)
EOF

run_cgen -f ${cpu_file}

# Find line with "bad-command".
bad_loc=$(grep -n "bad-command" ${cpu_file} | sed -e 's/:.*$//')

if ! grep -q "unknown entry type:" ${test_output_file}
then
    fail "bad command not detected"
elif ! grep -q "${cpu_file}:${bad_loc}:.*: unknown entry type:" ${test_output_file}
then
    fail "bad command not detected on correct line"
fi

finish
