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]

[testsuite, commited] Fix error message in scan-hidden/scan-not-hidden


Hi,

consider test-case visibility-1.c:
...
/* Test visibility attribute on function definition. */
/* { dg-do compile } */
/* { dg-require-visibility "" } */
/* { dg-final { scan-hidden "foo" } } */

void
__attribute__((visibility ("hidden")))
foo()
{ }
...

which passes with:
...
PASS: gcc.dg/visibility-1.c (test for excess errors)
PASS: gcc.dg/visibility-1.c scan-hidden hidden[ \t_]*foo
...

If we drop the argument to scan-hidden:
...
-/* { dg-final { scan-hidden "foo" } } */
+/* { dg-final { scan-hidden } } */
...

we get:
...
PASS: gcc.dg/visibility-1.c (test for excess errors)
PASS: gcc.dg/visibility-1.c scan-hidden hidden[ \t_]*
...

while we want:
...
PASS: gcc.dg/visibility-1.c (test for excess errors)
ERROR: gcc.dg/visibility-1.c: error executing dg-final: scan-hidden: too few arguments
UNRESOLVED: gcc.dg/visibility-1.c: error executing dg-final: scan-hidden: too few arguments
...

The problem originates from the fact that scan-hidden uses
'set args [lreplace $args 0 0 ...]' also when '[llength $args] == 0', which
results in '[llength $args] == 1'.

This patch fixes that, both for scan-hidden and scan-not-hidden.

Committed as obvious.

Thanks,
- Tom

[testsuite] Fix error message in scan-hidden/scan-not-hidden

2018-05-21  Tom de Vries  <tom@codesourcery.com>

	* lib/scanasm.exp (scan-hidden, scan-not-hidden): Handle being called
	with no arguments.

---
 gcc/testsuite/lib/scanasm.exp | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp
index 61e0f3f..5c574d5 100644
--- a/gcc/testsuite/lib/scanasm.exp
+++ b/gcc/testsuite/lib/scanasm.exp
@@ -125,11 +125,13 @@ proc scan-hidden { args } {
     set filename [lindex $testcase 0]
     set output_file "[file rootname [file tail $filename]].s"
 
-    set symbol [lindex $args 0]
+    if { [llength $args] > 0 } {
+	set symbol [lindex $args 0]
 
-    set hidden_scan [hidden-scan-for $symbol]
+	set hidden_scan [hidden-scan-for $symbol]
 
-    set args [lreplace $args 0 0 "$hidden_scan"]
+	set args [lreplace $args 0 0 "$hidden_scan"]
+    }
 
     dg-scan "scan-hidden" 1 $testcase $output_file $args
 }
@@ -143,10 +145,12 @@ proc scan-not-hidden { args } {
     set filename [lindex $testcase 0]
     set output_file "[file rootname [file tail $filename]].s"
 
-    set symbol [lindex $args 0]
-    set hidden_scan [hidden-scan-for $symbol]
+    if { [llength $args] > 0 } {
+	set symbol [lindex $args 0]
+	set hidden_scan [hidden-scan-for $symbol]
 
-    set args [lreplace $args 0 0 "$hidden_scan"]
+	set args [lreplace $args 0 0 "$hidden_scan"]
+    }
 
     dg-scan "scan-not-hidden" 0 $testcase $output_file $args
 }


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