This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC/PATCH] compat.exp support to add to ways to compile a test


I'd like to add support to compat.exp to specify sets of compiler
options to use for a specific test, but would like some feedback about
whether this is the right approach.

The patch below supports a new test framework option, dg-compat-options,
to append a new list of pairs of options to the existing COMPAT_OPTIONS,
which by default is just "" "".  Here's the documentation for it, to be
added to as-yet-unreviewed text in sourcebuild.texi that lists test
framework commands that can be used in compatibility tests:

  @item dg-compat-options
  This command can be used in @file{@var{testname}_main.@var{suffix}}.
  The first argument is a list of pairs of options to append to
  @env{COMPAT_OPTIONS} for this test.  The optional second argument is
  a target specification for which that list is used.  Look for examples
  in the testsuite.

With the existing support for COMPAT_OPTIONS, GCC uses the first set of
options in each pair and if an alternate compiler is provided then it
uses the second set.  If ALT_*_UNDER_TEST is "same" then the two parts
of a test are compiled with the same compiler but different options.

Some things I'm not sure about:

  - Should pairs of options specified for a particular test be used in
    addition to what's defined in COMPAT_OPTIONS (as this patch does) or
    in place of it?  Is there need for an option in the command to say
    whether it's appended to or replaces COMPAT_OPTIONS?

  - The option pairs apply to both test_x.c and test_.c, but there might
    be cases for which we'd want specific options for only one file.  I
    suppose I can hack this stuff some more if that comes up.

  - COMPAT_OPTIONS provides a way to use the binary compatibility tests
    with a different compiler and to specify its options, which might be
    different from those used by GCC.  Since I first wrote this stuff
    we've added support for particular options to be used for specific
    files, and those might be options that are only used by GCC, so it's
    probably not much of a change from there to specify additional
    GCC-only options within a test.  The primary purpose, after all, is
    to test GCC against earlier versions of itself.

Janis

--- /home/janis/cvs/gcc_mainline/gcc/gcc/testsuite/lib/compat.exp	2004-07-27 14:26:21.000000000 -0700
+++ ./compat.exp	2004-07-27 14:24:53.000000000 -0700
@@ -147,6 +147,40 @@ proc compat-run { testname objlist dest 
 }
 
 #
+# dg-compat-options -- process a list of pairs of option sets for a
+# particular test, along with limitations on targets where it's used
+#
+# ARGS is the argument list for the command
+#  first element is the line number where it appears in the test
+#  second element is the list of pairs, e.g.
+#     { { { -O3 } { -O3 } } { { -g } { -g } } { { -O3 } { -g } } }
+#  third (optional) element is the target list, e.g.
+#     { target powerpc*-*-* }
+#
+# The list of option pairs is appended to COMPAT_OPTIONS.
+#
+proc dg-compat-options { args } {
+    upvar 2 local_option_list local_option_list
+
+    if { [llength $args] > 3 } {
+	error "[lindex $args 0]: too many arguments"
+	return
+    }
+    if { [llength $args ] >= 3 } {
+	switch [dg-process-target [lindex $args 2]] {
+	    "S" { set local_option_list \
+		  [concat [lindex $args 1] $local_option_list ] }
+	    "N" { }
+	    "F" { error "[lindex $args 0]: `xfail' not allowed here" }
+	    "P" { error "[lindex $args 0]: `xfail' not allowed here" }
+	}
+    } else {
+	set local_option_list [concat [lindex $args 1] $local_option_list ]
+    }
+    verbose "dg-compat-options: $local_option_list" 2
+}
+
+#
 # compat-get-options-main -- get target requirements for a test and
 # options for the primary source file and the test as a whole
 #
@@ -159,10 +193,14 @@ proc compat-get-options-main { src } {
     # dg-require-* sets dg-do-what.
     upvar dg-do-what dg-do-what 
 
+    # dg-compat-options sets compat_option_list
+    upvar local_option_list local_option_list
+
     set tmp [dg-get-options $src]
     foreach op $tmp {
 	set cmd [lindex $op 0]
 	if { ![string compare "dg-options" $cmd] \
+	     || [string match "dg-compat-options" $cmd] \
 	     || [string match "dg-require-*" $cmd]  } {
 	    set status [catch "$op" errmsg]
 	    if { $status != 0 } {
@@ -211,7 +249,8 @@ proc compat-get-options { src } {
 		unresolved "$src: $errmsg for \"$op\""
 		return
 	    }
-	} elseif { [string match "dg-require-*" $cmd] } {
+	} elseif { [string match "dg-require-*" $cmd] \
+		   || [string match "dg-compat-options" $cmd] } {
 	    warning "compat.exp does not support $cmd in secondary source files"
 	} else {
 	    # Ignore unrecognized dg- commands, but warn about them.
@@ -240,6 +279,8 @@ proc compat-execute { src1 sid use_alt }
     global compiler_conditional_xfail_data
     global dg-do-what-default
 
+    set local_option_list $option_list
+
     # Get extra flags for this test from the primary source file, and
     # process other dg-* options that this suite supports.  Warn about
     # unsupported flags.
@@ -293,7 +334,7 @@ proc compat-execute { src1 sid use_alt }
     # Loop through all of the option lists used for this test.
 
     set count 0
-    foreach option_pair $option_list {
+    foreach option_pair $local_option_list {
 
 	# Pick out each set of options.
 	set tst_option [lindex $option_pair 0]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]