diff options
author | Iain Sandoe <iain.sandoe@sandoe-acoustics.co.uk> | 2010-03-24 22:51:08 +0000 |
---|---|---|
committer | Janis Johnson <janis@gcc.gnu.org> | 2010-03-24 22:51:08 +0000 |
commit | 9debda96f54bfe9cbc2dbecc580d5099765432fe (patch) | |
tree | 11901b325f62a78fe1486b244860a4328085cc85 | |
parent | 94ad7adc73607526003a3592bc5fdfd2d4b51182 (diff) | |
download | gcc-9debda96f54bfe9cbc2dbecc580d5099765432fe.zip gcc-9debda96f54bfe9cbc2dbecc580d5099765432fe.tar.gz gcc-9debda96f54bfe9cbc2dbecc580d5099765432fe.tar.bz2 |
re PR testsuite/42348 (Syntax of dg-skip-if in two obj-c++ tests)
2010-03-24 Iain Sandoe <iain.sandoe@sandoe-acoustics.co.uk>
PR testsuite/42348
* lib/target-supports.exp: Add support for ObjC/ObjC++ tools in
standard tests.
(check_effective_target_objc2): New proc.
(check_effective_target_next_runtime): New proc.
* lib/objc.exp: Determine which runtime is in force and support it.
* lib/obj-c++.exp: Ditto.
From-SVN: r157715
-rw-r--r-- | gcc/testsuite/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/testsuite/lib/obj-c++.exp | 104 | ||||
-rw-r--r-- | gcc/testsuite/lib/objc.exp | 95 | ||||
-rw-r--r-- | gcc/testsuite/lib/target-supports.exp | 41 |
4 files changed, 184 insertions, 66 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d1598dd..12021bc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2010-03-24 Iain Sandoe <iain.sandoe@sandoe-acoustics.co.uk> + + PR testsuite/42348 + * lib/target-supports.exp: Add support for ObjC/ObjC++ tools in + standard tests. + (check_effective_target_objc2): New proc. + (check_effective_target_next_runtime): New proc. + * lib/objc.exp: Determine which runtime is in force and support it. + * lib/obj-c++.exp: Ditto. + 2010-03-24 Jason Merrill <jason@redhat.com> PR c++/43502 diff --git a/gcc/testsuite/lib/obj-c++.exp b/gcc/testsuite/lib/obj-c++.exp index b61dc55..45208e6 100644 --- a/gcc/testsuite/lib/obj-c++.exp +++ b/gcc/testsuite/lib/obj-c++.exp @@ -42,10 +42,10 @@ proc obj-c++_version { } { obj-c++_init - # ignore any arguments after the command + # Ignore any arguments after the command. set compiler [lindex $OBJCXX_UNDER_TEST 0] - # verify that the compiler exists + # Verify that the compiler exists. if { [is_remote host] || [which $compiler] != 0 } then { set tmp [remote_exec host "$compiler -v"] set status [lindex $tmp 0]; @@ -61,7 +61,7 @@ proc obj-c++_version { } { clone_output "Couldn't determine version of [which $compiler]\n" } } else { - # compiler does not exist (this should have already been detected) + # Compiler does not exist (this should have already been detected) warning "$compiler does not exist" } } @@ -93,7 +93,7 @@ proc obj-c++_include_flags { paths } { # # obj-c++_link_flags -- provide new version of obj-c++_link_flags -# (originally from libgloss.exp) which knows about the gcc tree structure +# (originally from libgloss.exp) which knows about the gcc tree structure. # proc obj-c++_link_flags { paths } { @@ -115,27 +115,31 @@ proc obj-c++_link_flags { paths } { append ld_library_path ":${gccpath}/lib" } if [file exists "${gccpath}/libg++/libg++.a"] { - append flags "-L${gccpath}/libg++ " + append flags " -L${gccpath}/libg++ " append ld_library_path ":${gccpath}/libg++" } if [file exists "${gccpath}/libstdc++/libstdc++.a"] { - append flags "-L${gccpath}/libstdc++ " + append flags " -L${gccpath}/libstdc++ " append ld_library_path ":${gccpath}/libstdc++" } if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] { + # Allow for %s spec substitutions + append flags " -B${gccpath}/libstdc++-v3/src/.libs " append flags " -L${gccpath}/libstdc++-v3/src/.libs " append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs" } # Look for libstdc++.${shlib_ext}. if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] { + # Allow for %s spec substitutions + append flags " -B${gccpath}/libstdc++-v3/src/.libs " append flags " -L${gccpath}/libstdc++-v3/src/.libs " append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs" } if [file exists "${gccpath}/libiberty/libiberty.a"] { - append flags "-L${gccpath}/libiberty " + append flags " -L${gccpath}/libiberty " } if [file exists "${gccpath}/librx/librx.a"] { - append flags "-L${gccpath}/librx " + append flags " -L${gccpath}/librx " } set objcpath "[get_multilibs]" @@ -145,24 +149,23 @@ proc obj-c++_link_flags { paths } { } # Now check if we have a shared only build. if { $libobjc_dir == ""} { - set libobjc_dir \ - [lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}] - } - if { $libobjc_dir == ""} { - set libobjc_dir \ - [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}] + set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}] + if { $libobjc_dir == ""} { + set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}] + } } verbose "libobjc_dir: $libobjc_dir" if { $libobjc_dir != "" } { set libobjc_dir [file dirname ${libobjc_dir}] - append flags "-L${libobjc_dir}" + # Allow for %s spec substitutions + append flags " -B${libobjc_dir} " + append flags " -L${libobjc_dir} " append ld_library_path ":${libobjc_dir}" } append ld_library_path \ [gcc-set-multilib-library-path $OBJCXX_UNDER_TEST] - } else { global tool_root_dir; @@ -264,7 +267,7 @@ proc obj-c++_init { args } { if { [string match "*-*-darwin*" $target_triplet] } { lappend ALWAYS_OBJCXXFLAGS "ldflags=-multiply_defined suppress" - } + } verbose -log "ALWAYS_OBJCXXFLAGS set to $ALWAYS_OBJCXXFLAGS" @@ -284,43 +287,74 @@ proc obj-c++_target_compile { source dest type options } { global OBJCXX_UNDER_TEST global shlib_ext - lappend options "libs=-lobjc" set shlib_ext [get_shlib_extension] - verbose "shared lib extension: $shlib_ext" + verbose "input-options: $options" 4 + + # We have to figure out which runtime will be used on darwin because + # we need to add the include path for the gnu runtime if that is in + # use. + # First, set the default... + if { [istarget "*-*-darwin*"] } { + set nextruntime 1 + } else { + set nextruntime 0 + } + verbose "initial next runtime state : $nextruntime" 2 + # Next, see if we define the option in dg-options... + foreach opt $options { + if [regexp ".*-fnext-runtime.*" $opt] { + set nextruntime 1 + } + if [regexp ".*-fgnu-runtime.*" $opt] { + set nextruntime 0 + } + } + verbose "next runtime state after dg opts: $nextruntime" 2 + + set tgt [target_info name] + if [board_info $tgt exists multilib_flags] { + set lb [board_info $tgt multilib_flags] + verbose "board multilib_flags $lb" 2 + foreach opt $lb { + if [regexp ".*-fnext-runtime.*" $opt] { + set nextruntime 1 + } + if [regexp ".*-fgnu-runtime.*" $opt] { + set nextruntime 0 + } + } + } + verbose "next runtime state after any multilib opts: $nextruntime" 2 + + lappend options "libs=-lobjc" if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { lappend options "libs=${gluefile}" lappend options "ldflags=${wrap_flags}" } - # If we have built libobjc along with the compiler (which usually - # _is not_ the case on Mac OS X systems), point the test harness + # If we have built libobjc along with the compiler, point the test harness # at it (and associated headers). set objcpath "[get_multilibs]" set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a] if { $libobjc_dir == ""} { - verbose "see if we have -fgnu-runtime in options" - if [regexp ".*-fgnu-runtime.*" "${options}" ] { - set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a] - } + set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a] } if { $libobjc_dir == ""} { - set libobjc_dir \ - [lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}] - } - if { $libobjc_dir == ""} { - verbose "see if we have -fgnu-runtime in options" - if [regexp ".*-fgnu-runtime.*" "${options}"] { - set libobjc_dir \ - [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}] + set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}] + if { $libobjc_dir == ""} { + set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}] } } if { $libobjc_dir != "" } { - set objc_include_dir "${srcdir}/../../libobjc" - lappend options "additional_flags=-I${objc_include_dir}" + # If we are using the gnu runtime, add its includes. + if { $nextruntime == 0 } { + set objc_include_dir "${srcdir}/../../libobjc" + lappend options "additional_flags=-I${objc_include_dir}" + } } lappend options "additional_flags=[libio_include_flags]" diff --git a/gcc/testsuite/lib/objc.exp b/gcc/testsuite/lib/objc.exp index 9d7bac0..3355a0f 100644 --- a/gcc/testsuite/lib/objc.exp +++ b/gcc/testsuite/lib/objc.exp @@ -44,7 +44,7 @@ proc default_objc_version { } { objc_init - # ignore any arguments after the command + # Ignore any arguments after the command. set compiler [lindex $OBJC_UNDER_TEST 0] if ![is_remote host] { @@ -53,7 +53,7 @@ proc default_objc_version { } { set compiler_name $compiler } - # verify that the compiler exists + # Verify that the compiler exists. if { $compiler_name != 0 } then { set tmp [remote_exec host "$compiler -v"] set status [lindex $tmp 0] @@ -65,7 +65,7 @@ proc default_objc_version { } { clone_output "Couldn't determine version of $compiler_name: $output\n" } } else { - # compiler does not exist (this should have already been detected) + # Compiler does not exist (this should have already been detected). warning "$compiler does not exist" } } @@ -98,7 +98,8 @@ proc objc_init { args } { global gcc_warning_prefix global gcc_error_prefix - # We set LC_ALL and LANG to C so that we get the same error messages as expected. + # We set LC_ALL and LANG to C so that we get the same error messages as + # expected. setenv LC_ALL C setenv LANG C @@ -141,11 +142,48 @@ proc objc_target_compile { source dest type options } { global ld_library_path global objc_libgcc_s_path global shlib_ext - + + set shlib_ext [get_shlib_extension] set ld_library_path ".:${objc_libgcc_s_path}" + + # We have to figure out which runtime will be used on darwin because + # we need to add the include path for the gnu runtime if that is in + # use. + # First set the default... + if { [istarget "*-*-darwin*"] } { + set nextruntime 1 + } else { + set nextruntime 0 + } + verbose "initial next runtime state : $nextruntime" 2 + # Next, see if we define the option in dg-options... + foreach opt $options { + if [regexp ".*-fnext-runtime.*" $opt] { + set nextruntime 1 + } + if [regexp ".*-fgnu-runtime.*" $opt] { + set nextruntime 0 + } + } + verbose "next runtime state after dg opts: $nextruntime" 2 + + set tgt [target_info name] + if [board_info $tgt exists multilib_flags] { + set lb [board_info $tgt multilib_flags] + verbose "board multilib_flags $lb" 2 + foreach opt $lb { + if [regexp ".*-fnext-runtime.*" $opt] { + set nextruntime 1 + } + if [regexp ".*-fgnu-runtime.*" $opt] { + set nextruntime 0 + } + } + } + verbose "next runtime state after any multilib opts: $nextruntime" 2 + lappend options "libs=-lobjc" - set shlib_ext [get_shlib_extension] - verbose "shared lib extension: $shlib_ext" + verbose "shared lib extension: $shlib_ext" 3 if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } { lappend options "libs=${gluefile}" @@ -167,42 +205,43 @@ proc objc_target_compile { source dest type options } { set options [concat "{additional_flags=$TOOL_OPTIONS}" $options] } - # If we have built libobjc along with the compiler (which usually - # _is not_ the case on Mac OS X systems), point the test harness + # If we have built libobjc along with the compiler, point the test harness # at it (and associated headers). set objcpath "[get_multilibs]" set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a] - if { $libobjc_dir == ""} { - verbose "see if we have -fgnu-runtime in options" - if [regexp ".*-fgnu-runtime.*" "${options}"] { + if { $libobjc_dir == "" } { + # On darwin there is, potentially, a gnu runtime too. set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a] - } } - # Now check if we have a shared only build. - if { $libobjc_dir == ""} { - set libobjc_dir \ - [lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}] - } - if { $libobjc_dir == ""} { - verbose "see if we have -fgnu-runtime in options" - if [regexp ".*-fgnu-runtime.*" "${options}"] { - set libobjc_dir \ - [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}] + # Perhaps we didn't build static libs. + if { $libobjc_dir == "" } { + set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}] + # On darwin there is, potentially, a gnu runtime too. + if { $libobjc_dir == "" } { + set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}] } } + if { $libobjc_dir != "" } { - set objc_include_dir "${srcdir}/../../libobjc" - lappend options "additional_flags=-I${objc_include_dir}" + # If we are using the gnu runtime, add its includes. + if { $nextruntime == 0 } { + set objc_include_dir "${srcdir}/../../libobjc" + lappend options "additional_flags=-I${objc_include_dir}" + verbose "adding gnu runtime include dir: $objc_include_dir " + } set libobjc_dir [file dirname ${libobjc_dir}] - set objc_link_flags "-L${libobjc_dir}" + # Allow for %s spec substitutions.. + set objc_link_flags " -B${libobjc_dir} " + lappend options "additional_flags=${objc_link_flags}" + set objc_link_flags " -L${libobjc_dir} " lappend options "additional_flags=${objc_link_flags}" append ld_library_path ":${libobjc_dir}" } if { $type == "precompiled_header" } { # If we generating a precompiled header, we have say this is an - # objective-C header + # objective-C header. set source [concat "-x objective-c-header" $source] } lappend options "compiler=$OBJC_UNDER_TEST" @@ -214,7 +253,7 @@ proc objc_target_compile { source dest type options } { } # -# objc_pass -- utility to record a testcase passed +# objc_pass -- utility to record a testcase passed. # proc objc_pass { testcase cflags } { diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 924a595..126ae38 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -29,10 +29,17 @@ # If ARGS is not empty, its first element is a string that # should be added to the command line. # -# Assume by default that CONTENTS is C code. C++ code should contain -# "// C++" and Fortran code should contain "! Fortran". +# Assume by default that CONTENTS is C code. +# Otherwise, code should contain: +# "// C++" for c++, +# "! Fortran" for Fortran code, +# "/* ObjC", for ObjC +# and "// ObjC++" for ObjC++ +# If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to +# allow for ObjC/ObjC++ specific flags. proc check_compile {basename type contents args} { global tool + verbose "check_compile tool: $tool for $basename" if { [llength $args] > 0 } { set options [list "additional_flags=[lindex $args 0]"] @@ -42,8 +49,17 @@ proc check_compile {basename type contents args} { switch -glob -- $contents { "*! Fortran*" { set src ${basename}[pid].f90 } "*// C++*" { set src ${basename}[pid].cc } - default { set src ${basename}[pid].c } + "*// ObjC++*" { set src ${basename}[pid].mm } + "*/* ObjC*" { set src ${basename}[pid].m } + default { + switch -- $tool { + "objc" { set src ${basename}[pid].m } + "obj-c++" { set src ${basename}[pid].mm } + default { set src ${basename}[pid].c } + } + } } + set compile_type $type switch -glob $type { assembly { set output ${basename}[pid].s } @@ -1188,6 +1204,25 @@ proc check_cxa_atexit_available { } { }] } +proc check_effective_target_objc2 { } { + return [check_no_compiler_messages objc2 object { + #ifdef __OBJC2__ + int dummy[1]; + #else + #error + #endif + }] +} + +proc check_effective_target_next_runtime { } { + return [check_no_compiler_messages objc2 object { + #ifdef __NEXT_RUNTIME__ + int dummy[1]; + #else + #error + #endif + }] +} # Return 1 if we're generating 32-bit code using default options, 0 # otherwise. |