From 7fc8c87785ce0816ebd8740ce275d1384dbe2a5a Mon Sep 17 00:00:00 2001
From: bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 16 Oct 2006 17:22:38 +0000
Subject: [PATCH] 2006-10-16  Benjamin Kosnik  <bkoz@redhat.com>

	PR libstdc++/29095 continued
	* testsuite/lib/libstdc++.exp (v3_target_compile_as_c): Additions
	so that testing not in the build directory works for the "C"
	target language.



git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117788 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libstdc++-v3/ChangeLog                   |  7 +++++++
 libstdc++-v3/testsuite/lib/libstdc++.exp | 21 ++++++++++++++++++---
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 0aed5e0f8a74..29b5e3cb60e6 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2006-10-16  Benjamin Kosnik  <bkoz@redhat.com>
+
+	PR libstdc++/29095 continued
+	* testsuite/lib/libstdc++.exp (v3_target_compile_as_c): Additions
+	so that testing not in the build directory works for the "C"
+	target language.
+
 2006-10-16  Jakub Jelinek  <jakub@redhat.com>
 
 	* include/bits/basic_string.tcc (_Rep::_S_create): Call
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 1f877be99ea4..4030e6819b52 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -88,6 +88,7 @@ proc libstdc++_init { testfile } {
     global gluefile wrap_flags
     global ld_library_path
     global target_triplet
+    global flags_file
 
     # We set LC_ALL and LANG to C so that we get the same error
     # messages as expected.
@@ -191,9 +192,9 @@ proc libstdc++_init { testfile } {
             set includes [exec sh $flags_file --build-includes]
         } else {
             set cxx [transform "g++"]
-            set includes "-I${srcdir}/util"
             set cxxldflags ""
             set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0" 
+            set includes "-I${srcdir}/util"
         }
     }
 
@@ -357,6 +358,7 @@ proc v3_target_compile_as_c { source dest type options } {
     global gluefile 
     global wrap_flags
     global includes
+    global flags_file
 
     if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
         lappend options "libs=${gluefile}"
@@ -364,12 +366,25 @@ proc v3_target_compile_as_c { source dest type options } {
     }
 
     set tname [target_info name]
-    set cc_final [board_info $tname compiler]
-    set cxxlibglossflags  [libgloss_link_flags]
+    set cc [board_info $tname compiler]
+    set cc_final $cc
+    set cxxlibglossflags [libgloss_link_flags]
     set cc_final [concat $cc_final $cxxlibglossflags]
     set cc_final [concat $cc_final $includes]
     regsub -all ".nostdinc.." $cc_final "" cc_final
 
+    # This is needed for "C" tests, as this type of test may need the
+    # C++ includes. And if we're not testing in the build directory,
+    # the includes variable is not likely to include the necessary info.
+    if { ![file exists $flags_file] } {
+	set version [exec ${cc} -dumpversion]
+	set machine [exec ${cc} -dumpmachine]
+	set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname [exec ${cc} --print-prog-name=cc1]]]]]]
+	set includesbase "${comp_base_dir}/include/c++/${version}"
+	set includestarget "${includesbase}/${machine}"
+	set cc_final [concat $cc_final "-I$includesbase -I$includestarget"]
+    }
+
     lappend options "compiler=$cc_final"
     lappend options "timeout=600"
 
-- 
GitLab