1 # Copyright (C) 2012-2017 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
17 # Test for error messages when a bad register name, an out of range operand, or
18 # invalid syntax is used. Adapted from Ben Elliston's load-hazard testcase.
20 # Run GAS and check that it emits the desired error for the test case.
22 # file -- name of the test case to assemble.
23 # testname -- a string describing the test.
24 # warnpattern -- a regular expression, suitable for use by the Tcl
25 # regexp command, to decide if the warning string was emitted by
26 # the assembler to stderr.
28 proc mrisc1_error_test { file testname {warnpattern ""} } {
31 gas_run $file "" ">/dev/null"
32 verbose "output was $comp_output" 2
34 if {$warnpattern == ""} {
35 if {$comp_output == ""} { pass $testname } else { fail $testname }
39 if {[regexp "Error: $warnpattern" $comp_output]} {
46 if [istarget mt-*-*] {
47 foreach file [lsort [glob -nocomplain -- $srcdir/$subdir/bad*.s]] {
48 set file [file tail $file]
51 set warnpattern "unrecognized keyword/register name *"
54 set warnpattern "unrecognized form of instruction*"
57 set warnpattern "unrecognized keyword/register name *"
60 set warnpattern "unrecognized form of instruction*"
63 set warnpattern "Operand out of range. Must be between -32768 and 32767.*"
66 set warnpattern "Operand out of range. Must be between -32768 and 32767.*"
68 "badunsignedimmhigh.s" {
69 set warnpattern "operand out of range (65536 not between 0 and 65535)*"
71 "badunsignedimmlow.s" {
72 set warnpattern "operand out of range (65536 not between 0 and 65535)*"
74 "badsignedimmhigh.s" {
75 set warnpattern "operand out of range.*"
78 set warnpattern "operand out of range.*"
81 set warnpattern "unrecognized instruction *"
84 set warnpattern "junk at end of line *"
87 error "no expected result specified for $file"
92 mrisc1_error_test $file "assembler emits error for $file" $warnpattern