OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / gcc-dg.exp
index d790396..d12ff52 100644 (file)
@@ -183,9 +183,39 @@ proc gcc-dg-prune { system text } {
        return "::unsupported::memory full"
     }
 
+    # Likewise, if we see ".text exceeds local store range" or
+    # similar.
+    if {[string match "spu-*" $system] && \
+           [string match "*exceeds local store range*" $text]} {
+       # The format here is important.  See dg.exp.
+       return "::unsupported::memory full"
+    }
+
     return $text
 }
 
+# Replace ${tool}_load with a wrapper to provide for an expected nonzero
+# exit status.  Multiple languages include this file so this handles them
+# all, not just gcc.
+if { [info procs ${tool}_load] != [list] \
+      && [info procs saved_${tool}_load] == [list] } {
+    rename ${tool}_load saved_${tool}_load
+
+    proc ${tool}_load { program args } {
+       global tool
+       global shouldfail
+       set result [eval [list saved_${tool}_load $program] $args]
+       if { $shouldfail != 0 } {
+           switch [lindex $result 0] {
+               "pass" { set status "fail" }
+               "fail" { set status "pass" }
+           }
+           set result [list $status [lindex $result 1]]
+       }
+       return $result
+    }
+}
+
 # Utility routines.
 
 #
@@ -244,6 +274,7 @@ proc gcc-dg-debug-runtest { target_compile trivial opt_opts testcases } {
                    "additional_flags=$type"]
            if { ! [string match "*: target system does not support the * debug format*" \
                    $comp_output] } {
+               remove-build-file "trivial.S"
                foreach level {1 "" 3} {
                    lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
                    foreach opt $opt_opts {
@@ -270,7 +301,12 @@ proc gcc-dg-debug-runtest { target_compile trivial opt_opts testcases } {
 
        foreach flags $DEBUG_TORTURE_OPTIONS {
            set doit 1
-           if { [string match {*/debug-[126].c} "$nshort"] \
+
+           # These tests check for information which may be deliberately
+           # suppressed at -g1.
+           if { ([string match {*/debug-[126].c} "$nshort"] \
+                  || [string match {*/enum-1.c} "$nshort"] \
+                  || [string match {*/enum-[12].C} "$nshort"]) \
                    && [string match "*1" [lindex "$flags" 0] ] } {
                set doit 0
            }
@@ -419,6 +455,70 @@ proc cleanup-modules { modlist } {
     }
 }
 
+# Scan Fortran modules for a given regexp.
+#
+# Argument 0 is the module name
+# Argument 1 is the regexp to match
+proc scan-module { args } {
+    set modfilename [string tolower [lindex $args 0]].mod
+    set fd [open $modfilename r]
+    set text [read $fd]
+    close $fd
+
+    upvar 2 name testcase
+    if [regexp -- [lindex $args 1] $text] {
+      pass "$testcase scan-module [lindex $args 1]"
+    } else {
+      fail "$testcase scan-module [lindex $args 1]"
+    }
+}
+
+# Verify that the compiler output file exists, invoked via dg-final.
+proc output-exists { args } {
+    # Process an optional target or xfail list.
+    if { [llength $args] >= 1 } {
+       switch [dg-process-target [lindex $args 0]] {
+           "S" { }
+           "N" { return }
+           "F" { setup_xfail "*-*-*" }
+           "P" { }
+       }
+    }
+
+    # Access variables from gcc-dg-test-1.
+    upvar 2 name testcase
+    upvar 2 output_file output_file
+
+    if [file exists $output_file] {
+       pass "$testcase output-exists $output_file"
+    } else {
+       fail "$testcase output-exists $output_file"
+    }
+}
+
+# Verify that the compiler output file does not exist, invoked via dg-final.
+proc output-exists-not { args } {
+    # Process an optional target or xfail list.
+    if { [llength $args] >= 1 } {
+       switch [dg-process-target [lindex $args 0]] {
+           "S" { }
+           "N" { return }
+           "F" { setup_xfail "*-*-*" }
+           "P" { }
+       }
+    }
+
+    # Access variables from gcc-dg-test-1.
+    upvar 2 name testcase
+    upvar 2 output_file output_file
+
+    if [file exists $output_file] {
+       fail "$testcase output-exists-not $output_file"
+    } else {
+       pass "$testcase output-exists-not $output_file"
+    }
+}
+
 # We need to make sure that additional_* are cleared out after every
 # test.  It is not enough to clear them out *before* the next test run
 # because gcc-target-compile gets run directly from some .exp files
@@ -436,12 +536,14 @@ if { [info procs saved-dg-test] == [list] } {
        global additional_prunes
        global errorInfo
        global compiler_conditional_xfail_data
+       global shouldfail
 
        if { [ catch { eval saved-dg-test $args } errmsg ] } {
            set saved_info $errorInfo
            set additional_files ""
            set additional_sources ""
            set additional_prunes ""
+           set shouldfail 0
            if [info exists compiler_conditional_xfail_data] {
                unset compiler_conditional_xfail_data
            }
@@ -450,10 +552,47 @@ if { [info procs saved-dg-test] == [list] } {
        set additional_files ""
        set additional_sources ""
        set additional_prunes ""
+       set shouldfail 0
        if [info exists compiler_conditional_xfail_data] {
            unset compiler_conditional_xfail_data
        }
     }
 }
 
+# Modify the regular expression saved by a DejaGnu message directive to
+# include a prefix and to force the expression to match a single line.
+# MSGPROC is the procedure to call.
+# MSGPREFIX is the prefix to prepend.
+# DGARGS is the original argument list.
+
+proc process-message { msgproc msgprefix dgargs } {
+    upvar dg-messages dg-messages
+
+    # Process the dg- directive, including adding the regular expression
+    # to the new message entry in dg-messages.
+    set msgcnt [llength ${dg-messages}]
+    catch { eval $msgproc $dgargs }
+
+    # If the target expression wasn't satisfied there is no new message.
+    if { [llength ${dg-messages}] == $msgcnt } {
+       return;
+    }
+
+    # Prepend the message prefix to the regular expression and make
+    # it match a single line.
+    set newentry [lindex ${dg-messages} end]
+    set expmsg [lindex $newentry 2]
+    set expmsg "$msgprefix\[^\n]*$expmsg"
+    set newentry [lreplace $newentry 2 2 $expmsg]
+    set dg-messages [lreplace ${dg-messages} end end $newentry]
+    verbose "process-message:\n${dg-messages}" 2
+}
+
+# Look for messages that don't have standard prefixes.
+
+proc dg-message { args } {
+    upvar dg-messages dg-messages
+    process-message dg-warning "" $args
+}
+
 set additional_prunes ""