#
# vtable tests
#
proc run_list_test { name opts } {
    global srcdir subdir
    set testname "vtable $name"
    set file $srcdir/$subdir/$name
    gas_run ${name}.s $opts ">&dump.out"
    if { [regexp_diff "dump.out" "${file}.l"] } then {
	fail $testname
	verbose "output is [file_contents "dump.out"]" 2
	return
    }
    pass $testname
}

# These tests are not (yet) supported on some targets.
proc vtable_setup_xfails { } {
    setup_xfail "alpha*-*" "arc-*" "avr-*" "d30v-*"
    setup_xfail "h8300*-*" "hppa*64*-*-*hpux*"
    setup_xfail "i370-*" "i860-*" "i960-*" "ia64-*" "ip2k-*"
    setup_xfail "mn10200-*" "or32-*" "sparc64*-*"
}

# Vtable bits are only supported by ELF targets.
if { (   [istarget "*-*-elf*"] || [istarget "*-*-linux*"])
     && ![istarget *-*-linux*aout*]
     && ![istarget *-*-linux*ecoff*]
     && ![istarget *-*-linux*oldld*] } then {

    vtable_setup_xfails
    run_dump_test "inherit0"

    # This particular test is supposed to fail..
    run_list_test "inherit1" "-al"

    # The vtable entry results are different on Rel and Rela targets.
    vtable_setup_xfails
    if {[istarget "arm*-*"]
	|| [istarget "arc-*"]
	|| [istarget "d10v-*"]
	|| [istarget "dlx-*"]
	|| [istarget "i*86-*"] 
	|| [istarget "m32r-*"] 
	|| ([istarget "mips*-*"]
	    && ! [istarget "mips64*-*-linux*"]
	    && ! [istarget "mips*-*-irix6*"])
	|| [istarget "m68hc*-*"] 
	|| [istarget "or32-*"] 
	|| [istarget "strongarm*-*"] 
	|| [istarget "xscale*-*"] } then {

	run_dump_test "entry0"

    } else {

	run_dump_test "entry1"

    }
}
