[PATCH] logical expressions in test directive target/xfail lists

Janis Johnson janis187@us.ibm.com
Thu Jan 27 20:21:00 GMT 2005


This patch implements and documents support for logical expressions as
selectors in xfail and target lists in test directives.  It uses
proposal 2 from http://gcc.gnu.org/ml/gcc/2005-01/msg01264.html (about
which I've received zero comments) with the exception that the operand
of a logical operator can be a list of target triplets.

This has been tested with additions to my generated test framework tests
and with changes to several tests that can be made to be XFAIL or
UNSUPPORTED for odd combinations of targets and effective-targets using
this new support; those will be submitted once this is in.  I've run
the entire C anc C++ testsuites with the change and have a bootstrap
underway of all languages but Ada that will run all of the testsuites
with the patch, just to make sure there are no surprises.  It's also
been tested, of course, using "make info" and "make dvi".  All testing
was on powerpc64-unknown-linux-gnu.

Any objections to this on mainline?  If not, it's going in tomorrow.

(The only objections I would expect, by the way, are from people who use
or plan to use drop-in replacements to DejaGnu and are concerned about
adding support in those other systems.  If I can do this easily in TCL
then you guys can do it in whatever you're using.)

2005-01-27  Janis Johnson  <janis187@us.ibm.com>

Index: gcc/doc/sourcebuild.texi
===================================================================
RCS file: /opt/gcc-cvs/gcc/gcc/doc/sourcebuild.texi,v
retrieving revision 1.64
diff -u -p -r1.64 sourcebuild.texi
--- gcc/doc/sourcebuild.texi	20 Jan 2005 22:15:25 -0000	1.64
+++ gcc/doc/sourcebuild.texi	24 Jan 2005 23:50:33 -0000
@@ -919,17 +919,26 @@ DejaGnu directives, which know nothing a
 DejaGnu directives must precede GCC directives.
 
 Several test directives include selectors which are usually preceded by
-the keyword @code{target} or @code{xfail}.  A selector is one or
-more target triplets, possibly including wildcard characters, or else a
-single effective-target keyword.  Depending on the context, the selector
-specifies whether a test is skipped and reported as unsupported or is
-expected to fail.  Use @samp{*-*-*} to match any target.
-
+the keyword @code{target} or @code{xfail}.  A selector is: one or more
+target triplets, possibly including wildcard characters; a single
+effective-target keyword; or a logical expression.  Depending on the
+context, the selector specifies whether a test is skipped and reported
+as unsupported or is expected to fail.  Use @samp{*-*-*} to match any
+target.
 Effective-target keywords are defined in @file{target-supports.exp} in
-the GCC testsuite or, in the case of unusual effective targets that are
-used only for a limited number of tests, in @file{.exp} files in the
-same directory as the tests.  There is no mechanism to combine or negate
-effective-target keywords.
+the GCC testsuite.
+
+A selector expression appears within curly braces and uses a single
+logical operator: one of @option{!}, @option{&&}, or @option{||}.  An
+operand is another selector expression, an effective-target keyword,
+a single target triplet, or a list of target triplets within quotes or
+curly braces.  For example:
+
+@smallexample
+@{ target @{ ! "hppa*-*-* ia64*-*-*" @} @}
+@{ target @{ powerpc*-*-* && lp64 @} @}
+@{ xfail @{ lp64 || vect_no_align @} @}
+@end smallexample
 
 @table @code
 @item @{ dg-do @var{do-what-keyword} [@{ target/xfail @var{selector} @}] @}
Index: gcc/testsuite/lib/gcc-dg.exp
===================================================================
RCS file: /opt/gcc-cvs/gcc/gcc/testsuite/lib/gcc-dg.exp,v
retrieving revision 1.48
diff -u -p -r1.48 gcc-dg.exp
--- gcc/testsuite/lib/gcc-dg.exp	24 Jan 2005 18:23:08 -0000	1.48
+++ gcc/testsuite/lib/gcc-dg.exp	26 Jan 2005 19:18:20 -0000
@@ -522,17 +522,74 @@ if { [info procs saved-dg-test] == [list
 # selector is one of:
 #    xfail target-triplet-1 ...
 #    xfail effective-target-keyword
+#    xfail selector-expression
 #    target target-triplet-1 ...
 #    target effective-target-keyword
+#    target selector-expression
 #
 # For a target list the result is "S" if the target is selected, "N" otherwise.
 # For an xfail list the result is "F" if the target is affected, "P" otherwise.
+#
+# A selector expression appears within curly braces and uses a single logical
+# operator: !, &&, or ||.  An operand is another selector expression, an
+# effective-target keyword, or a list of target triplets within quotes or
+# curly braces.
 
 if { [info procs saved-dg-process-target] == [list] } {
     rename dg-process-target saved-dg-process-target
 
+    # Evaluate an operand within a selector expression.
+    proc selector_opd { op } {
+	set selector "target"
+	lappend selector $op
+	set answer [ expr { [dg-process-target $selector] == "S" } ]
+	verbose "selector_opd: `$op' $answer" 2
+	return $answer
+    }
+
+    # Evaluate a target triplet list within a selector expression.
+    # Unlike other operands, this needs to be expanded from a list to
+    # the same string as "target".
+    proc selector_list { op } {
+	set selector "target [join $op]"
+	set answer [ expr { [dg-process-target $selector] == "S" } ]
+	verbose "selector_list: `$op' $answer" 2
+	return $answer
+    }
+
+    # Evaluate a selector expression.
+    proc selector_expression { exp } {
+	if { [llength $exp] == 2 } {
+	    if [string match "!" [lindex $exp 0]] {
+		set op1 [lindex $exp 1]
+		set answer [expr { ! [selector_opd $op1] }]
+	    } else {
+		# Assume it's a list of target triplets.
+		set answer [selector_list $exp]
+	    }
+	} elseif { [llength $exp] == 3 } {
+	    set op1 [lindex $exp 0]
+	    set opr [lindex $exp 1]
+	    set op2 [lindex $exp 2]
+	    if [string match "&&" $opr] {
+		set answer [expr { [selector_opd $op1] && [selector_opd $op2] }]
+	    } elseif [string match "||" $opr] {
+		set answer [expr { [selector_opd $op1] || [selector_opd $op2] }]
+	    } else {
+		# Assume it's a list of target triplets.
+		set answer [selector_list $exp]
+	    }
+	} else {
+	    # Assume it's a list of target triplets.
+	    set answer [selector_list $exp]
+	}
+
+	verbose "selector_expression: `$exp' $answer" 2
+	return $answer
+    }
+
     proc dg-process-target { args } {
-        verbose "replacement dg-process-target" 2
+	verbose "replacement dg-process-target: `$args'" 2
 	
 	# Extract the 'what' keyword from the argument list.
 	set selector [string trim [lindex $args 0]]
@@ -551,6 +608,14 @@ if { [info procs saved-dg-process-target
 	if [is-effective-target-keyword $rest] {
 	    # The selector is an effective target keyword.
 	    if [is-effective-target $rest] {
+		return [expr { $what == "xfail" ? "F" : "S" }]
+	    } else {
+		return [expr { $what == "xfail" ? "P" : "N" }]
+	    }
+	}
+
+	if [string match "{*}" $rest] {
+	    if [selector_expression [lindex $rest 0]] {
 		return [expr { $what == "xfail" ? "F" : "S" }]
 	    } else {
 		return [expr { $what == "xfail" ? "P" : "N" }]



More information about the Gcc-patches mailing list