diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index bc53511387d61bed08d81ef075bd511296eec957..dd5d17330ac913ffcb5b6259579579930a877684 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2005-10-04  Janis Johnson  <janis187@us.ibm.com>
+
+	* lib/target-supports.exp (check_effective_target_fortran_large_real,
+	check_effective_target_fortran_large_int): Replace cached result
+	when target changes.
+
 2005-10-04  Devang Patel  <dpatel@apple.com>
 
 	* gcc.dg/i386-sse-vect-types.c: New.
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 6cbbf146ef3f59238f9638ce5446b5687c9eb3f7..b98e3ceb94f1ed558c2d43a3988026c2ae91ac30 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -411,12 +411,30 @@ proc check_named_sections_available { } {
 }
 
 # Return 1 if the target supports Fortran real kinds larger than real(8),
-# 0 otherwise.  Cache the result.
+# 0 otherwise.
+#
+# When the target name changes, replace the cached result.
 
 proc check_effective_target_fortran_large_real { } {
     global et_fortran_large_real_saved
+    global et_fortran_large_real_target_name
     global tool
 
+    if { ![info exists et_fortran_large_real_target_name] } {
+	set et_fortran_large_real_target_name ""
+    }
+
+    # If the target has changed since we set the cached value, clear it.
+    set current_target [current_target_name]
+    if { $current_target != $et_fortran_large_real_target_name } {
+	verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
+	set et_fortran_large_real_target_name $current_target
+	if [info exists et_fortran_large_real_saved] {
+	    verbose "check_effective_target_fortran_large_real: removing cached result" 2
+	    unset et_fortran_large_real_saved
+	}
+    }
+
     if [info exists et_fortran_large_real_saved] {
 	verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
     } else {
@@ -449,12 +467,30 @@ proc check_effective_target_fortran_large_real { } {
 }
 
 # Return 1 if the target supports Fortran integer kinds larger than
-# integer(8), 0 otherwise.  Cache the result.
+# integer(8), 0 otherwise.
+#
+# When the target name changes, replace the cached result.
 
 proc check_effective_target_fortran_large_int { } {
     global et_fortran_large_int_saved
+    global et_fortran_large_int_target_name
     global tool
 
+    if { ![info exists et_fortran_large_int_target_name] } {
+	set et_fortran_large_int_target_name ""
+    }
+
+    # If the target has changed since we set the cached value, clear it.
+    set current_target [current_target_name]
+    if { $current_target != $et_fortran_large_int_target_name } {
+	verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
+	set et_fortran_large_int_target_name $current_target
+	if [info exists et_fortran_large_int_saved] {
+	    verbose "check_effective_target_fortran_large_int: removing cached result" 2
+	    unset et_fortran_large_int_saved
+	}
+    }
+
     if [info exists et_fortran_large_int_saved] {
 	verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
     } else {