# Copyright (C) 1988, 90-96, 1997 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  

# Please email any bugs, comments, and/or additions to this file to:
# bug-gcc@prep.ai.mit.edu

# This file was written by Rob Savoye. (rob@cygnus.com)

#
# These tests come from Torbjorn Granlund (tege@cygnus.com)
# C torture test suite.
#

if $tracelevel then {
    strace $tracelevel
}

# load support procs
load_lib c-torture.exp
load_lib gcc-dg.exp

################## ADD NEXT CASE HERE (NOT AT THE END) ##################

# 921210-1
set lines [gcc_target_compile $srcdir/$subdir/921210-1.c "" preprocess ""]
set lines [prune [split [prune_warnings [prune_gcc_output $lines]] "\n"] ""]
set line [lindex $lines [expr [llength $lines]-1]]
regsub -all " " $line "" clean
if [expr [string compare $clean "(a->f+1)+1"]==0] then {
    pass "921210-1.c"
} else {
    fail "921210-1.c"
}

# 920521-1
c-torture 920521-1.c "-S"

# 920520-1
c-torture 920520-1.c "-S"

# 920717-1
if [isnative] then {
    set lines [gcc_target_compile "$srcdir/$subdir/920717-x.c" "920717-x.o" object {additional_flags="-w"}]
    if ![string match "" $lines] then {
	fail "920717-x.c"
    } else {
	# This is a completely bogus test. Sorry.
	catch exec "rm -f 920717-y.o"
	send_log "cc -c $srcdir/$subdir/920717-y.c 2>/dev/null >/dev/null\n"
	catch exec "cc -c $srcdir/$subdir/920717-y.c 2>/dev/null >/dev/null"
	if ![file exists "920717-y.o"] then {
	    send_log "c89 -c $srcdir/$subdir/920717-y.c 2>/dev/null >/dev/null\n"
	    catch exec "c89 -c $srcdir/$subdir/920717-y.c 2>/dev/null >/dev/null"
	}
	if [file exists "920717-y.o"] then {
	    set lines [gcc_target_compile "920717-y.o x.o" "x" executable ""]
	    if [string match "" $lines] then {
		pass "920717-1.c"
	    } else {
		fail "920717-1.c"
	    }
	}
    }
}

# 920730-1
if [isnative] then {
    c-torture "920730-1.c"
    c-torture "920730-1.c" "-traditional"
}

# 920413-1
c-torture 920413-1.c "-Wtraditional"

# 930510-1
dg-init
dg-runtest $srcdir/$subdir/930510-1.c "" ""
dg-finish

# 951130-1
c-torture 951130-1.c "-Werror"

# 960224-1
c-torture 960224-1.c "-E -ansi -pedantic-errors"

# 960224-2
#c-torture 960224-2.c "-E -ansi -pedantic-errors"
