[testsuite/guality,committed] Use relative line numbers in vla-1.c

Message ID 20180701160525.7b7uangkqnuvccjh@delia
State New
Headers show
Series
  • [testsuite/guality,committed] Use relative line numbers in vla-1.c
Related show

Commit Message

Tom de Vries July 1, 2018, 4:05 p.m.
Hi,

this patch replaces absolute with relative line numbers in guality/vla-1.c.

The test-case has a line:
...
$ cat -n gcc/testsuite/gcc.dg/guality/vla-1.c
    17    return a[0];          /* { dg-final { gdb-test 17 "sizeof (a)" "6" } } */
...
which corresponds to relative line number '.'.  This was not supported in
get-absolute-line, so this patch adds support for that as well.

Committed as obvious.

Thanks,
- Tom

[testsuite/guality] Use relative line numbers in vla-1.c

2018-07-01  Tom de Vries  <tdevries@suse.de>

	* lib/gcc-dg.exp (get-absolute-line): Handle '.'.
	* gcc.dg/guality/vla-1.c: Use relative line numbers.

---
 gcc/testsuite/gcc.dg/guality/vla-1.c | 8 ++++----
 gcc/testsuite/lib/gcc-dg.exp         | 4 ++++
 2 files changed, 8 insertions(+), 4 deletions(-)

Patch

diff --git a/gcc/testsuite/gcc.dg/guality/vla-1.c b/gcc/testsuite/gcc.dg/guality/vla-1.c
index 651465428ac..264b9f3f92b 100644
--- a/gcc/testsuite/gcc.dg/guality/vla-1.c
+++ b/gcc/testsuite/gcc.dg/guality/vla-1.c
@@ -13,15 +13,15 @@  int __attribute__((noinline))
 f1 (int i)
 {
   char a[i + 1];
-  a[0] = 5;		/* { dg-final { gdb-test 17 "i" "5" } } */
-  return a[0];		/* { dg-final { gdb-test 17 "sizeof (a)" "6" } } */
+  a[0] = 5;		/* { dg-final { gdb-test .+1 "i" "5" } } */
+  return a[0];		/* { dg-final { gdb-test . "sizeof (a)" "6" } } */
 }
 
 int __attribute__((noinline))
 f2 (int i)
 {
-  short a[i * 2 + 7];	/* { dg-final { gdb-test 24 "i" "5" } } */
-  bar (a);		/* { dg-final { gdb-test 24 "sizeof (a)" "17 * sizeof (short)" } } */
+  short a[i * 2 + 7];	/* { dg-final { gdb-test .+1 "i" "5" } } */
+  bar (a);		/* { dg-final { gdb-test . "sizeof (a)" "17 * sizeof (short)" } } */
   return a[i + 4];
 }
 
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 4f1796348c3..9e0b3f4ef95 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1066,6 +1066,10 @@  proc dg-line { linenr varname } {
 # Argument 1 is the relative line number or line number variable reference
 #
 proc get-absolute-line { useline line } {
+    if { "$line" == "." } {
+	return $useline
+    }
+
     if { [regsub "^\.\[+-\](\[0-9\]+)$" $line "\\1" num] && $useline != "" } {
 	# Handle relative line specification, .+1 or .-1 etc.
 	set num [expr $useline [string index $line 1] $num]