aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/lib/compat.exp
diff options
context:
space:
mode:
authorJanis Johnson <janis187@us.ibm.com>2003-07-21 21:24:27 +0000
committerJanis Johnson <janis187@us.ibm.com>2003-07-21 21:24:27 +0000
commit78d2be017ba1bf64ff98c6649168a14f6d339e47 (patch)
tree67c08346367763841fe6430445e149d68dd34559 /gcc/testsuite/lib/compat.exp
parent859fbf78dc1c1db755f8b6b630e2156bc2f54445 (diff)
* lib/compat.exp: Handle dg-options per source file.
* g++.dg/compat/abi/bitfield1_x.C: Specify dg-options. * g++.dg/compat/abi/bitfield1_y.C: Ditto. * g++.dg/compat/abi/bitfield2_x.C: Ditto. * g++.dg/compat/abi/bitfield2_y.C: Ditto. * g++.dg/compat/abi/vbase8-10_x.C: Ditto. * g++.dg/compat/abi/vbase8-10_y.C: Ditto. * g++.dg/compat/abi/vbase8-21_x.C: Ditto. * g++.dg/compat/abi/vbase8-21_y.C: Ditto. * g++.dg/compat/abi/vbase8-22_x.C: Ditto. * g++.dg/compat/abi/vbase8-22_y.C: Ditto. * g++.dg/compat/abi/vbase8-4_x.C: Ditto. * g++.dg/compat/abi/vbase8-4_y.C: Ditto. * g++.dg/compat/break/bitfield7_x.C: Ditto. * g++.dg/compat/break/bitfield7_y.C: Ditto. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@69649 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/lib/compat.exp')
-rw-r--r--gcc/testsuite/lib/compat.exp108
1 files changed, 75 insertions, 33 deletions
diff --git a/gcc/testsuite/lib/compat.exp b/gcc/testsuite/lib/compat.exp
index 67d60ecd80c..2926d0be680 100644
--- a/gcc/testsuite/lib/compat.exp
+++ b/gcc/testsuite/lib/compat.exp
@@ -49,18 +49,25 @@ if ![info exists COMPAT_OPTIONS] {
set option_list $COMPAT_OPTIONS
+load_lib dg.exp
+
#
# compat-obj -- compile to an object file
#
# SOURCE is the source file
# DEST is the object file
-# OPTIONS is the list of compiler options
+# OPTALL is the list of compiler options to use with all tests
+# OPTFILE is the list of compiler options to use with this file
# OPTSTR is the options to print with test messages
#
-proc compat-obj { source dest options optstr } {
+proc compat-obj { source dest optall optfile optstr } {
global testcase
global tool
+ # Set up the options for compiling this file.
+ set options ""
+ lappend options "additional_flags=$optfile $optall"
+
set comp_output [${tool}_target_compile "$source" "$dest" object $options]
${tool}_check_compile "$testcase $dest compile" $optstr $dest $comp_output
}
@@ -70,10 +77,11 @@ proc compat-obj { source dest options optstr } {
# TESTNAME is the mixture of object files to link
# OBJLIST is the list of object files to link
# DEST is the name of the executable
-# OPTIONS is a list of compiler and linker options to use
+# OPTALL is a list of compiler and linker options to use for all tests
+# OPTFILE is a list of compiler and linker options to use for this test
# OPTSTR is the list of options to list in messages
#
-proc compat-run { testname objlist dest options optstr } {
+proc compat-run { testname objlist dest optall optfile optstr } {
global testcase
global tool
@@ -86,6 +94,10 @@ proc compat-run { testname objlist dest options optstr } {
}
}
+ # Set up the options for linking this test.
+ set options ""
+ lappend options "additional_flags=$optfile $optall"
+
# Link the objects into an executable.
set comp_output [${tool}_target_compile "$objlist" $dest executable \
"$options"]
@@ -108,6 +120,48 @@ proc compat-run { testname objlist dest options optstr } {
}
#
+# compat-flags -- get special tool flags to use for a source file
+#
+# SRC is the full patchname of the source file.
+# The result is a list of options to use.
+#
+# This code is copied from proc dg-test in dg.exp from DejaGNU.
+#
+proc compat-get-options { src } {
+ # Define our own special function `unknown` so we catch spelling errors.
+ # But first rename the existing one so we can restore it afterwards.
+ catch {rename dg-save-unknown ""}
+ rename unknown dg-save-unknown
+ proc unknown { args } {
+ return -code error "unknown dg option: $args"
+ }
+
+ # dg-options sets a variable called dg-extra-tool-flags.
+ set dg-extra-tool-flags ""
+ set tmp [dg-get-options $src]
+ foreach op $tmp {
+ set cmd [lindex $op 0]
+ if ![string compare "dg-options" $cmd] {
+ set status [catch "$op" errmsg]
+ if { $status != 0 } {
+ perror "src: $errmsg for \"$op\"\n"
+ unresolved "$src: $errmsg for \"$op\""
+ return
+ }
+ } else {
+ # Ignore unrecognized dg- commands, but warn about them.
+ warning "compat.exp does not support $cmd"
+ }
+ }
+
+ # Restore normal error handling.
+ rename unknown ""
+ rename dg-save-unknown unknown
+
+ return ${dg-extra-tool-flags}
+}
+
+#
# compat-execute -- compile with compatible compilers
#
# SRC1 is the full pathname of the main file of the testcase.
@@ -123,27 +177,19 @@ proc compat-execute { src1 sid use_alt } {
global testcase
global gluefile
- # Use the dg-options mechanism to specify extra flags for this test.
- # FIXME: This does not handle other uses of dg-options, and it only
- # processes the first one.
- set extra_tool_flags ""
- set tmp [grep $src1 "{\[ \t\]\*dg-options.*\[ \t\]\+}"]
- if ![string match "" $tmp] {
- set tmp0 [lindex $tmp 0]
- # Extract the compiler options.
- regexp "dg-options\[ \t\]\+(.*)\[ \t\]\+\}" \
- $tmp0 all args
- # Sometime the options are in quotes, sometimes not.
- regsub -all "\"" $args "" args
- set extra_tool_flags $args
- }
-
# Set up the names of the other source files.
regsub "_main.*" $src1 "" base
regsub ".*/" $base "" base
regsub "_main" $src1 "_x" src2
regsub "_main" $src1 "_y" src3
+ # Use the dg-options mechanism to specify extra flags for this test.
+ # The extra flags in each file are used to compile that file, and the
+ # extra flags in *_main.* are also used for linking.
+ set extra_flags_1 [compat-get-options $src1]
+ set extra_flags_2 [compat-get-options $src2]
+ set extra_flags_3 [compat-get-options $src3]
+
# Define the names of the object files.
regsub "sid" "sid_main_tst.o" $sid obj1
regsub "sid" "sid_x_tst.o" $sid obj2_tst
@@ -180,11 +226,6 @@ proc compat-execute { src1 sid use_alt } {
}
verbose "Testing $testcase, $optstr" 1
- set tst_options ""
- set alt_options ""
- lappend tst_options "additional_flags=$extra_tool_flags $tst_option"
- lappend alt_options "additional_flags=$extra_tool_flags $alt_option"
-
# There's a unique name for each executable we generate, based on
# the set of options and how the pieces of the tests are compiled.
set execname1 "${execbase}-${count}1"
@@ -202,28 +243,29 @@ proc compat-execute { src1 sid use_alt } {
# later. Skip this if we don't have an alternate compiler.
if { $use_alt != 0 } then {
compat-use-alt-compiler
- compat-obj "$src2" "$obj2_alt" $alt_options $optstr
- compat-obj "$src3" "$obj3_alt" $alt_options $optstr
+ compat-obj "$src2" "$obj2_alt" $alt_option $extra_flags_2 $optstr
+ compat-obj "$src3" "$obj3_alt" $alt_option $extra_flags_3 $optstr
}
# Compile pieces with the compiler under test.
compat-use-tst-compiler
- compat-obj "$src1" "$obj1" $tst_options $optstr
- compat-obj "$src2" "$obj2_tst" $tst_options $optstr
- compat-obj "$src3" "$obj3_tst" $tst_options $optstr
+ compat-obj "$src1" "$obj1" $tst_option $extra_flags_1 $optstr
+ compat-obj "$src2" "$obj2_tst" $tst_option $extra_flags_2 $optstr
+ compat-obj "$src3" "$obj3_tst" $tst_option $extra_flags_3 $optstr
# Link (using the compiler under test), run, and clean up tests.
compat-run "${obj2_tst}-${obj3_tst}" \
- "$obj1 $obj2_tst $obj3_tst" $execname1 $tst_options $optstr
+ "$obj1 $obj2_tst $obj3_tst" $execname1 \
+ $tst_option $extra_flags_1 $optstr
# If we've got an alternate compiler try some combinations.
if { $use_alt != 0 } then {
compat-run "${obj2_tst}-${obj3_alt}" "$obj1 $obj2_tst $obj3_alt" \
- $execname2 $tst_options $optstr
+ $execname2 $tst_option $extra_flags_1 $optstr
compat-run "${obj2_alt}-${obj3_tst}" "$obj1 $obj2_alt $obj3_tst" \
- $execname3 $tst_options $optstr
+ $execname3 $tst_option $extra_flags_1 $optstr
compat-run "${obj2_alt}-${obj3_alt}" "$obj1 $obj2_alt $obj3_alt" \
- $execname4 $tst_options $optstr
+ $execname4 $tst_option $extra_flags_1 $optstr
}
# Clean up object files.