From e489eeb9331efd07f584794f69db5ced3cc959da Mon Sep 17 00:00:00 2001
From: Mark Mitchell <mark@codesourcery.com>
Date: Tue, 10 Jun 2003 02:57:48 +0000
Subject: [PATCH] gcc-dg.exp (dg-test): Clear additional_files and
 additional_sources.

	* lib/gcc-dg.exp (dg-test): Clear additional_files and
	additional_sources.

From-SVN: r67696
---
 gcc/testsuite/ChangeLog      |  5 +++++
 gcc/testsuite/lib/gcc-dg.exp | 28 ++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 39ccaf690a02..c660eca4838c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2003-06-09  Mark Mitchell  <mark@codesourcery.com>
+
+	* lib/gcc-dg.exp (dg-test): Clear additional_files and
+	additional_sources.
+
 2003-05-21  David Taylor  <dtaylor@emc.com>
 
 	* gcc.dg/Wpadded.c: New file.
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index aade663aa780..1feadc4a0802 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -294,3 +294,31 @@ proc dg-require-gc-sections { args } {
 	return
     }
 }
+
+# We need to make sure that additional_files and additional_sources
+# are both 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 (outside of any test).  (Those
+# uses should eventually be eliminated.) 
+
+# Because the DG framework doesn't provide a hook that is run at the
+# end of a test, we must replace dg-test with a wrapper.
+
+if { [info procs saved-dg-test] == [list] } {
+    rename dg-test saved-dg-test
+
+    proc dg-test { args } {
+	global additional_files
+	global additional_sources
+	global errorInfo
+
+	if { [ catch { eval saved-dg-test $args } errmsg ] } {
+	    set saved_info $errorInfo
+	    set additional_files ""
+	    set additional_sources ""
+	    error $errmsg $saved_info
+	}
+	set additional_files ""
+	set additional_sources ""
+    }
+}
-- 
GitLab