similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/cabi1.d
rename to gcc/testsuite/gdc.test/runnable_cxx/cabi1.d
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/cpp_abi_tests.d
rename to gcc/testsuite/gdc.test/runnable_cxx/cpp_abi_tests.d
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/cppa.d
rename to gcc/testsuite/gdc.test/runnable_cxx/cppa.d
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/externmangle.d
rename to gcc/testsuite/gdc.test/runnable_cxx/externmangle.d
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/externmangle2.d
rename to gcc/testsuite/gdc.test/runnable_cxx/externmangle2.d
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/extra-files/cabi2.cpp
rename to gcc/testsuite/gdc.test/runnable_cxx/extra-files/cabi2.cpp
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/extra-files/cpp_abi_tests.cpp
rename to gcc/testsuite/gdc.test/runnable_cxx/extra-files/cpp_abi_tests.cpp
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/extra-files/cppb.cpp
rename to gcc/testsuite/gdc.test/runnable_cxx/extra-files/cppb.cpp
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/extra-files/externmangle.cpp
rename to gcc/testsuite/gdc.test/runnable_cxx/extra-files/externmangle.cpp
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/extra-files/externmangle2.cpp
rename to gcc/testsuite/gdc.test/runnable_cxx/extra-files/externmangle2.cpp
new file mode 100644
@@ -0,0 +1,46 @@
+# Copyright (C) 2012-2020 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 3 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 GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# Runnable C++ tests for the D2 testsuite.
+
+# Load support procs.
+load_lib gdc-dg.exp
+load_lib gdc-utils.exp
+
+# If the D runtime library is missing, bail.
+if { ![check_effective_target_d_runtime] } {
+ return
+}
+
+# We are mixing D and C++ code, need to pull in libstdc++
+global GDC_INCLUDE_CXX_FLAGS
+set GDC_INCLUDE_CXX_FLAGS 1
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+if [check_no_compiler_messages extern_c++_tests assembly {
+ // C++
+ int main() { return 0; }
+}] {
+ gdc-do-test [glob -nocomplain $srcdir/$subdir/*.d]
+}
+
+set GDC_INCLUDE_CXX_FLAGS 0
+
+# All done.
+dg-finish
@@ -404,6 +404,7 @@ proc gdc-do-test { testcases } {
set options [gdc-permute-options [lsort -unique $PERMUTE_ARGS]]
switch $dir {
+ runnable_cxx -
runnable {
for { set i 0 } { $i<[llength $options] } { incr i } {
set flags [lindex $options $i]
@@ -69,6 +69,7 @@ proc gdc_version { } {
proc gdc_include_flags { paths } {
global srcdir
+ global GDC_INCLUDE_CXX_FLAGS
global TESTING_IN_BUILD_TREE
set flags ""
@@ -77,6 +78,12 @@ proc gdc_include_flags { paths } {
return "${flags}"
}
+ if [info exists GDC_INCLUDE_CXX_FLAGS] {
+ set include_cxx_flags $GDC_INCLUDE_CXX_FLAGS
+ } else {
+ set include_cxx_flags 0
+ }
+
set gccpath ${paths}
if { $gccpath != "" } {
@@ -88,11 +95,13 @@ proc gdc_include_flags { paths } {
append flags "-I${srcdir}/../../libphobos/src "
# For the tests that mix C++ and D, need to know where headers are located.
- set odir [lookfor_file ${gccpath} libstdc++-v3]
- if { ${odir} != "" } {
- set cxxflags [exec sh ${odir}/scripts/testsuite_flags --build-includes]
- set idx [lsearch $cxxflags "-nostdinc++"]
- append flags [lreplace $cxxflags $idx $idx]
+ if $include_cxx_flags {
+ set odir [lookfor_file ${gccpath} libstdc++-v3]
+ if { ${odir} != "" && [file exists ${odir}/scripts/testsuite_flags] } {
+ set cxxflags [exec sh ${odir}/scripts/testsuite_flags --build-includes]
+ set idx [lsearch $cxxflags "-nostdinc++"]
+ append flags [lreplace $cxxflags $idx $idx]
+ }
}
return "$flags"
@@ -106,6 +115,7 @@ proc gdc_link_flags { paths } {
global srcdir
global ld_library_path
global GDC_UNDER_TEST
+ global GDC_INCLUDE_CXX_FLAGS
global shlib_ext
global SHARED_OPTION
@@ -117,6 +127,12 @@ proc gdc_link_flags { paths } {
set SHARED_OPTION ""
verbose "shared lib extension: $shlib_ext"
+ if [info exists GDC_INCLUDE_CXX_FLAGS] {
+ set include_cxx_flags $GDC_INCLUDE_CXX_FLAGS
+ } else {
+ set include_cxx_flags 0
+ }
+
if { $gccpath != "" } {
# Path to libgphobos.spec.
append flags "-B${gccpath}/libphobos/src "
@@ -148,11 +164,13 @@ proc gdc_link_flags { paths } {
if [file exists "${gccpath}/libiberty/libiberty.a"] {
append flags "-L${gccpath}/libiberty "
}
- # For the tests that mix C++ and D, we should try and handle this better.
- if { [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] \
- || [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] } {
- append flags "-L${gccpath}/libstdc++-v3/src/.libs "
- append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
+ # For the tests that mix C++ and D, need to know where library is located.
+ if $include_cxx_flags {
+ if { [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] \
+ || [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] } {
+ append flags "-L${gccpath}/libstdc++-v3/src/.libs "
+ append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
+ }
}
append ld_library_path [gcc-set-multilib-library-path $GDC_UNDER_TEST]
} else {
@@ -172,6 +190,13 @@ proc gdc_link_flags { paths } {
if { $libiberty != "" } {
append flags "-L${libiberty} "
}
+ if $include_cxx_flags {
+ set libstdcpp [lookfor_file ${tool_root_dir} libstdc++]
+ if { $libstdcpp != "" } {
+ append flags "-L${libstdcpp} "
+ append ld_library_path ":${libstdcpp}"
+ }
+ }
}
set_ld_library_path_env_vars
@@ -184,18 +209,14 @@ proc gdc_link_flags { paths } {
#
proc gdc_init { args } {
- global subdir
global gdc_initialized
global base_dir
global tmpdir
global libdir
global gluefile wrap_flags
- global objdir srcdir
- global ALWAYS_DFLAGS
- global TOOL_EXECUTABLE TOOL_OPTIONS
+ global TOOL_EXECUTABLE
global GDC_UNDER_TEST
global TESTING_IN_BUILD_TREE
- global TEST_ALWAYS_FLAGS
global gcc_warning_prefix
global gcc_error_prefix
@@ -231,31 +252,6 @@ proc gdc_init { args } {
gdc_maybe_build_wrapper "${tmpdir}/d-testglue.o"
- set ALWAYS_DFLAGS ""
-
- # TEST_ALWAYS_FLAGS are flags that should be passed to every
- # compilation. They are passed first to allow individual
- # tests to override them.
- if [info exists TEST_ALWAYS_FLAGS] {
- lappend ALWAYS_DFLAGS "additional_flags=$TEST_ALWAYS_FLAGS"
- }
-
- if ![is_remote host] {
- if [info exists TOOL_OPTIONS] {
- lappend ALWAYS_DFLAGS "additional_flags=[gdc_include_flags [get_multilibs ${TOOL_OPTIONS}] ]"
- lappend ALWAYS_DFLAGS "ldflags=[gdc_link_flags [get_multilibs ${TOOL_OPTIONS}] ]"
- } else {
- lappend ALWAYS_DFLAGS "additional_flags=[gdc_include_flags [get_multilibs] ]"
- lappend ALWAYS_DFLAGS "ldflags=[gdc_link_flags [get_multilibs] ]"
- }
- }
-
- if [info exists TOOL_OPTIONS] {
- lappend ALWAYS_DFLAGS "additional_flags=$TOOL_OPTIONS"
- }
-
- verbose -log "ALWAYS_DFLAGS set to $ALWAYS_DFLAGS"
-
set gcc_warning_prefix "warning:"
set gcc_error_prefix "(fatal )?error:"
@@ -269,18 +265,44 @@ proc gdc_init { args } {
proc gdc_target_compile { source dest type options } {
global tmpdir
global gluefile wrap_flags
- global ALWAYS_DFLAGS
global GDC_UNDER_TEST
+ global TOOL_OPTIONS
+ global TEST_ALWAYS_FLAGS
if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
lappend options "libs=${gluefile}"
lappend options "ldflags=${wrap_flags}"
}
+ set always_dflags ""
+
+ # TEST_ALWAYS_FLAGS are flags that should be passed to every
+ # compilation. They are passed first to allow individual
+ # tests to override them.
+ if [info exists TEST_ALWAYS_FLAGS] {
+ lappend always_dflags "additional_flags=$TEST_ALWAYS_FLAGS"
+ }
+
+ if ![is_remote host] {
+ if [info exists TOOL_OPTIONS] {
+ lappend always_dflags "additional_flags=[gdc_include_flags [get_multilibs ${TOOL_OPTIONS}] ]"
+ lappend always_dflags "ldflags=[gdc_link_flags [get_multilibs ${TOOL_OPTIONS}] ]"
+ } else {
+ lappend always_dflags "additional_flags=[gdc_include_flags [get_multilibs] ]"
+ lappend always_dflags "ldflags=[gdc_link_flags [get_multilibs] ]"
+ }
+ }
+
+ if [info exists TOOL_OPTIONS] {
+ lappend always_dflags "additional_flags=$TOOL_OPTIONS"
+ }
+
+ verbose "always_dflags set to: $always_dflags"
+
lappend options "timeout=[timeout_value]"
lappend options "compiler=$GDC_UNDER_TEST"
- set options [concat "$ALWAYS_DFLAGS" $options]
+ set options [concat "$always_dflags" $options]
set options [dg-additional-files-options $options $source]
return [target_compile $source $dest $type $options]
}