Re: [PATCH, testsuite] Allow braces around relative line numbers

2017-04-15 Thread Tom de Vries

On 03/29/2017 12:23 AM, Jakub Jelinek wrote:

On Tue, Mar 28, 2017 at 08:27:54AM +0200, Tom de Vries wrote:

this patch fixes testsuite PR80220 - "relative line numbers don't work when
put between braces".


What is the advantage of putting the line numbers between braces?


I don't know of any advantages.


Isn't it easier to just drop those?


I've attached two patches:
- first patch implements a script
  contrib/tests-normalize-line-number.sh that removes braces around
  line numbers.
- second patch is the result of running the script.

Tested by running the patched test-cases.

Second patch OK for stage4/stage1 trunk?

[ I'm not sure if the first patch is useful enough to commit to contrib. ]

Thanks,
- Tom
Add contrib/tests-normalize-line-number.sh

2017-04-15  Tom de Vries  

	* tests-normalize-line-number.sh: New file.

---
 contrib/tests-normalize-line-number.sh | 78 ++
 1 file changed, 78 insertions(+)

diff --git a/contrib/tests-normalize-line-number.sh b/contrib/tests-normalize-line-number.sh
new file mode 100755
index 000..9ecba6a
--- /dev/null
+++ b/contrib/tests-normalize-line-number.sh
@@ -0,0 +1,78 @@
+#!/usr/bin/env python2
+
+# We hit a bug with python 3 when doing replace_in_file_p() with
+# ./libstdc++-v3/testsuite/27_io/basic_filebuf/cons/wchar_t/10132-1.cc, so let's
+# use python 2 and import the print function from python 3.
+from __future__ import print_function
+
+import os, re
+import fileinput
+
+# A non-negative number.
+number="[0-9][0-9]*"
+# Allow quotes around the number.
+number=(
+"(?:" +
+number + "|" +
+'"' + number + '"' + "|" +
+"'" + number + "'" +
+")"
+)
+# Directives using a line number.
+directive="dg-(?:error|warning|message|bogus)"
+# Line containing directive.
+directiveline=(
+"(.*\{\s*%s.*)" % directive + # Part before line number.  Save it.
+"\{\s*(%s)\s*\}" % number +   # A number in braces.  Save the number.
+"\s*\}" + # Closing brace of directive.
+"(.*)"# Rest of line.  Save it.
+)
+# Match the entire line
+directiveline=(
+"^" +
+directiveline +
+"$"
+)
+pattern=re.compile(directiveline)
+
+extensions="c|cc|C|cpp|f|F|[fF]03|[fF]08|[fF]90|[fF]95|go|h|i|m|mm|S|adb|ads"
+extensionspattern=re.compile(".*\.(?:" + extensions + ")$")
+
+def do_replace_in_file(file):
+for line in fileinput.input(files=file,inplace=True):
+match=pattern.search(line)
+if match:
+line=(
+match.group(1) + # Part before line number.
+match.group(2) + # Line number.
+" }" +   # Closing brace of directive.
+match.group(3)   # Rest of line.
+)
+line+="\n"
+
+print(line, end='')
+
+def replace_in_file_p(file):
+filehandle = open(file, 'r')
+for line in filehandle:
+match=pattern.search(line)
+if match:
+return True
+
+return False
+
+def do_testsuite_dir(testsuite_dir):
+for root, dirs, files in os.walk(testsuite_dir):
+for file in files:
+if extensionspattern.match(file):
+fullname=os.path.join(root, file)
+if replace_in_file_p(fullname):
+do_replace_in_file(fullname)
+
+def do_dir(rootdir):
+for root, dirs, files in os.walk(rootdir):
+for dir in dirs:
+if dir == "testsuite":
+do_testsuite_dir(os.path.join(root, dir))
+
+do_dir(".")
Remove braces around line number in dejagnu directive

2017-04-14  Tom de Vries  

	* g++.dg/parse/error11.C: Remove braces around line number in dejagnu
	  directive.
	* g++.dg/parse/error3.C: Same.
	* g++.old-deja/g++.pt/niklas01a.C: Same.
	* gcc.dg/990506-0.c: Same.
	* gcc.dg/cpp/19990413-1.c: Same.
	* gcc.dg/cpp/pragma-1.c: Same.
	* gcc.dg/cpp/pragma-2.c: Same.
	* gcc.dg/m-un-2.c: Same.
	* objc.dg/private-1.m: Same.

---
 gcc/testsuite/g++.dg/parse/error11.C  | 2 +-
 gcc/testsuite/g++.dg/parse/error3.C   | 2 +-
 gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C | 2 +-
 gcc/testsuite/gcc.dg/990506-0.c   | 4 ++--
 gcc/testsuite/gcc.dg/cpp/19990413-1.c | 2 +-
 gcc/testsuite/gcc.dg/cpp/pragma-1.c   | 4 ++--
 gcc/testsuite/gcc.dg/cpp/pragma-2.c   | 4 ++--
 gcc/testsuite/gcc.dg/m-un-2.c | 4 ++--
 gcc/testsuite/objc.dg/private-1.m | 2 +-
 9 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/gcc/testsuite/g++.dg/parse/error11.C b/gcc/testsuite/g++.dg/parse/error11.C
index 846e676..a67160b 100644
--- a/gcc/testsuite/g++.dg/parse/error11.C
+++ b/gcc/testsuite/g++.dg/parse/error11.C
@@ -50,7 +50,7 @@ void func(void)
   //  the special error message.
   Foo<: :B> k2; // { dg-bogus "cannot begin|alternate spelling" "smart error should not be triggered here" }
   Foo[:B> k1;   // { dg-bogus "cannot begin|alternate spelling" "smart error should not be triggered

[PATCH, gfortran] Cleanup the submodule tests

2017-04-15 Thread Dominique d'Humières
Hi!

Unless someone objects, I am planning to commit the following cleanup

--- ../_clean/gcc/testsuite/gfortran.dg/submodule_17.f082016-08-24 
21:57:16.0 +0200
+++ gcc/testsuite/gfortran.dg/submodule_17.f08  2017-04-15 10:19:32.0 
+0200
@@ -25,3 +25,4 @@ end submodule
   use hello_interface
   if (get() .ne. string) call abort
 end
+! { dg-final { cleanup-submodules "hello_interface@hello_implementation" } }
--- ../_clean/gcc/testsuite/gfortran.dg/submodule_22.f082016-11-27 
20:08:35.0 +0100
+++ gcc/testsuite/gfortran.dg/submodule_22.f08  2017-04-15 10:21:50.0 
+0200
@@ -45,3 +45,5 @@ contains
 s = 2.0
   end subroutine sub3
 end
+! { dg-final { cleanup-submodules "mtop@submod" } }
+! { dg-final { cleanup-submodules "mtop@subsubmod" } }
--- ../_clean/gcc/testsuite/gfortran.dg/submodule_23.f902017-02-19 
19:28:37.0 +0100
+++ gcc/testsuite/gfortran.dg/submodule_23.f90  2017-04-15 10:26:53.0 
+0200
@@ -27,3 +27,4 @@ end submodule
   use mod
   print *, fun1(10)
 end
+! { dg-final { cleanup-submodules "mod@submod" } }
--- ../_clean/gcc/testsuite/gfortran.dg/submodule_24.f082017-02-19 
22:13:44.0 +0100
+++ gcc/testsuite/gfortran.dg/submodule_24.f08  2017-04-15 10:11:15.0 
+0200
@@ -21,3 +21,4 @@ contains
 end procedure
!end subroutine ! gfortran accepted this invalid workaround
 end submodule
+! { dg-final { cleanup-submodules "foo_interface@foo_implementation" } }
--- ../_clean/gcc/testsuite/gfortran.dg/submodule_26.f082017-03-18 
13:14:10.0 +0100
+++ gcc/testsuite/gfortran.dg/submodule_26.f08  2017-04-15 10:13:03.0 
+0200
@@ -44,3 +44,4 @@ contains
   module procedure cgca_clvgp
   end procedure cgca_clvgp
 end submodule m3clvg_sm3
+! { dg-final { cleanup-submodules "cgca_m3clvg@m3clvg_sm3" } }
--- ../_clean/gcc/testsuite/gfortran.dg/submodule_27.f082017-03-18 
13:14:10.0 +0100
+++ gcc/testsuite/gfortran.dg/submodule_27.f08  2017-04-15 10:13:35.0 
+0200
@@ -42,3 +42,4 @@ end submodule m3clvg_sm3
   call cgca_clvgp (hello)
   if (trim (greeting) .ne. "hello") call abort
 end
+! { dg-final { cleanup-submodules "cgca_m3clvg@m3clvg_sm3" } }
--- ../_clean/gcc/testsuite/gfortran.dg/submodule_28.f082017-03-18 
13:48:04.0 +0100
+++ gcc/testsuite/gfortran.dg/submodule_28.f08  2017-04-15 10:14:32.0 
+0200
@@ -50,3 +50,4 @@ program hello
   call routine1(2)
   if (answer .ne. 4) call abort
 end program
+! { dg-final { cleanup-submodules "my_mod@my_submod" } }

Dominique



Re: [PATCH, gfortran] Cleanup the submodule tests

2017-04-15 Thread Janus Weil
Hi Dominique,

if I'm not mistaken, the cleanup of module file in the testsuite is
done automatically by now, right? Couldn't one do the same also for
submodules?

Cheers,
Janus



2017-04-15 10:34 GMT+02:00 Dominique d'Humières :
> Hi!
>
> Unless someone objects, I am planning to commit the following cleanup
>
> --- ../_clean/gcc/testsuite/gfortran.dg/submodule_17.f082016-08-24 
> 21:57:16.0 +0200
> +++ gcc/testsuite/gfortran.dg/submodule_17.f08  2017-04-15 10:19:32.0 
> +0200
> @@ -25,3 +25,4 @@ end submodule
>use hello_interface
>if (get() .ne. string) call abort
>  end
> +! { dg-final { cleanup-submodules "hello_interface@hello_implementation" } }
> --- ../_clean/gcc/testsuite/gfortran.dg/submodule_22.f082016-11-27 
> 20:08:35.0 +0100
> +++ gcc/testsuite/gfortran.dg/submodule_22.f08  2017-04-15 10:21:50.0 
> +0200
> @@ -45,3 +45,5 @@ contains
>  s = 2.0
>end subroutine sub3
>  end
> +! { dg-final { cleanup-submodules "mtop@submod" } }
> +! { dg-final { cleanup-submodules "mtop@subsubmod" } }
> --- ../_clean/gcc/testsuite/gfortran.dg/submodule_23.f902017-02-19 
> 19:28:37.0 +0100
> +++ gcc/testsuite/gfortran.dg/submodule_23.f90  2017-04-15 10:26:53.0 
> +0200
> @@ -27,3 +27,4 @@ end submodule
>use mod
>print *, fun1(10)
>  end
> +! { dg-final { cleanup-submodules "mod@submod" } }
> --- ../_clean/gcc/testsuite/gfortran.dg/submodule_24.f082017-02-19 
> 22:13:44.0 +0100
> +++ gcc/testsuite/gfortran.dg/submodule_24.f08  2017-04-15 10:11:15.0 
> +0200
> @@ -21,3 +21,4 @@ contains
>  end procedure
> !end subroutine ! gfortran accepted this invalid workaround
>  end submodule
> +! { dg-final { cleanup-submodules "foo_interface@foo_implementation" } }
> --- ../_clean/gcc/testsuite/gfortran.dg/submodule_26.f082017-03-18 
> 13:14:10.0 +0100
> +++ gcc/testsuite/gfortran.dg/submodule_26.f08  2017-04-15 10:13:03.0 
> +0200
> @@ -44,3 +44,4 @@ contains
>module procedure cgca_clvgp
>end procedure cgca_clvgp
>  end submodule m3clvg_sm3
> +! { dg-final { cleanup-submodules "cgca_m3clvg@m3clvg_sm3" } }
> --- ../_clean/gcc/testsuite/gfortran.dg/submodule_27.f082017-03-18 
> 13:14:10.0 +0100
> +++ gcc/testsuite/gfortran.dg/submodule_27.f08  2017-04-15 10:13:35.0 
> +0200
> @@ -42,3 +42,4 @@ end submodule m3clvg_sm3
>call cgca_clvgp (hello)
>if (trim (greeting) .ne. "hello") call abort
>  end
> +! { dg-final { cleanup-submodules "cgca_m3clvg@m3clvg_sm3" } }
> --- ../_clean/gcc/testsuite/gfortran.dg/submodule_28.f082017-03-18 
> 13:48:04.0 +0100
> +++ gcc/testsuite/gfortran.dg/submodule_28.f08  2017-04-15 10:14:32.0 
> +0200
> @@ -50,3 +50,4 @@ program hello
>call routine1(2)
>if (answer .ne. 4) call abort
>  end program
> +! { dg-final { cleanup-submodules "my_mod@my_submod" } }
>
> Dominique
>

2017-04-15 10:34 GMT+02:00 Dominique d'Humières :
> Hi!
>
> Unless someone objects, I am planning to commit the following cleanup
>
> --- ../_clean/gcc/testsuite/gfortran.dg/submodule_17.f082016-08-24 
> 21:57:16.0 +0200
> +++ gcc/testsuite/gfortran.dg/submodule_17.f08  2017-04-15 10:19:32.0 
> +0200
> @@ -25,3 +25,4 @@ end submodule
>use hello_interface
>if (get() .ne. string) call abort
>  end
> +! { dg-final { cleanup-submodules "hello_interface@hello_implementation" } }
> --- ../_clean/gcc/testsuite/gfortran.dg/submodule_22.f082016-11-27 
> 20:08:35.0 +0100
> +++ gcc/testsuite/gfortran.dg/submodule_22.f08  2017-04-15 10:21:50.0 
> +0200
> @@ -45,3 +45,5 @@ contains
>  s = 2.0
>end subroutine sub3
>  end
> +! { dg-final { cleanup-submodules "mtop@submod" } }
> +! { dg-final { cleanup-submodules "mtop@subsubmod" } }
> --- ../_clean/gcc/testsuite/gfortran.dg/submodule_23.f902017-02-19 
> 19:28:37.0 +0100
> +++ gcc/testsuite/gfortran.dg/submodule_23.f90  2017-04-15 10:26:53.0 
> +0200
> @@ -27,3 +27,4 @@ end submodule
>use mod
>print *, fun1(10)
>  end
> +! { dg-final { cleanup-submodules "mod@submod" } }
> --- ../_clean/gcc/testsuite/gfortran.dg/submodule_24.f082017-02-19 
> 22:13:44.0 +0100
> +++ gcc/testsuite/gfortran.dg/submodule_24.f08  2017-04-15 10:11:15.0 
> +0200
> @@ -21,3 +21,4 @@ contains
>  end procedure
> !end subroutine ! gfortran accepted this invalid workaround
>  end submodule
> +! { dg-final { cleanup-submodules "foo_interface@foo_implementation" } }
> --- ../_clean/gcc/testsuite/gfortran.dg/submodule_26.f082017-03-18 
> 13:14:10.0 +0100
> +++ gcc/testsuite/gfortran.dg/submodule_26.f08  2017-04-15 10:13:03.0 
> +0200
> @@ -44,3 +44,4 @@ contains
>module procedure cgca_clvgp
>end procedure cgca_clvgp
>  end submodule m3clvg_sm3
> +! { dg-final { cleanup-submodules "cgca_m3clvg@m3clvg_sm3" } }
> --- ../_clean/gcc/testsuite/gfortran.dg/subm

Re: [PATCH, gfortran] Cleanup the submodule tests

2017-04-15 Thread Dominique d'Humières

> Le 15 avr. 2017 à 13:00, Janus Weil  a écrit :
> 
> Hi Dominique,
> 
> if I'm not mistaken, the cleanup of module file in the testsuite is
> done automatically by now, right? Couldn't one do the same also for
> submodules?
> 
> Cheers,
> Janus
> 

This is indeed doable, but before I’ld like to improve the module cleanup with 
the following patch (+remove all the non-necessary module cleanup)

--- ../_clean/gcc/testsuite/lib/fortran-modules.exp 2017-01-01 
17:38:58.0 +0100
+++ gcc/testsuite/lib/fortran-modules.exp   2017-01-03 09:19:02.0 
+0100
@@ -79,10 +79,11 @@ proc list-module-names { files } {
 
 proc list-module-names-1 { file } {
 set result {}
-set tmp [grep $file "^\[ \t\]*((#)?\[ 
\t\]*include|\[mM\]\[oO\]\[dD\]\[uU\]\[lL\]\[eE\](?!\[ 
\t\]+\[pP\]\[rR\]\[oO\]\[cC\]\[eE\]\[dD\]\[uU\]\[rR\]\[eE\]\[ \t\]+))\[ 
\t\]+.*" line]
+if {[file isdirectory $file]} {return}
+set tmp [igrep $file "^\[ \t\]*((#)?\[ \t\]*include|module(?!\[ 
\t\]+procedure\[ \t\]+))\[ \t\]+.*" line]
 if {![string match "" $tmp]} {
foreach i $tmp {
-   regexp "(\[0-9\]+)\[ \t\]+(?:(?:#)?\[ \t\]*include\[ 
\t\]+)\[\"\](\[^\"\]*)\[\"\]" $i dummy lineno include_file
+   regexp -nocase "(\[0-9\]+)\[ \t\]+(?:(?:#)?\[ \t\]*include\[ 
\t\]+)\[\"\'\](\[^\"\'\]*)\[\"\'\]" $i dummy lineno include_file
if {[info exists include_file]} {
set dir [file dirname $file]
set inc "$dir/$include_file"
@@ -99,7 +100,7 @@ proc list-module-names-1 { file } {
}
continue
}
-   regexp "(\[0-9\]+)\[ 
\t\]+(?:(\[mM\]\[oO\]\[dD\]\[uU\]\[lL\]\[eE\]\[ 
\t\]+(?!\[pP\]\[rR\]\[oO\]\[cC\]\[eE\]\[dD\]\[uU\]\[rR\]\[eE\]\[ \t\]+)))(\[^ 
\t;\]*)" $i i lineno keyword mod
+   regexp -nocase "(\[0-9\]+)\[ \t\]+(?:(\module\[ \t\]+(?!procedure\[ 
\t\]+)))(\[^ \t;\]*)" $i i lineno keyword mod
if {![info exists lineno]} {
continue
}
@@ -111,3 +112,54 @@ proc list-module-names-1 { file } {
 }
 return $result
 }
+
+# Looks for case insensitive occurrences of a string in a file.
+# return:list of lines that matched or NULL if none match.
+# args:  first arg is the filename,
+#second is the pattern,
+#third are any options.
+# Options: line  - puts line numbers of match in list
+#
+proc igrep { args } {
+
+set file [lindex $args 0]
+set pattern [lindex $args 1]
+
+verbose "Grepping $file for the pattern \"$pattern\"" 3
+
+set argc [llength $args]
+if { $argc > 2 } {
+for { set i 2 } { $i < $argc } { incr i } {
+append options [lindex $args $i]
+append options " "
+}
+} else {
+set options ""
+}
+
+set i 0
+set fd [open $file r]
+while { [gets $fd cur_line]>=0 } {
+incr i
+if {[regexp -nocase -- "$pattern" $cur_line match]} {
+if {![string match "" $options]} {
+foreach opt $options {
+switch $opt {
+"line" {
+lappend grep_out [concat $i $match]
+}
+}
+}
+} else {
+lappend grep_out $match
+}
+}
+}
+close $fd
+unset fd
+unset i
+if {![info exists grep_out]} {
+set grep_out ""
+}
+return $grep_out
+}

Dominique



[PATCH] Cleanup dg directives

2017-04-15 Thread Dominique d'Humières
I am planning to commit as obvious the following changes

--- ../_clean/gcc/testsuite/gfortran.dg/deferred_character_3.f90
2015-11-15 15:12:11.0 +0100
+++ gcc/testsuite/gfortran.dg/deferred_character_3.f90  2017-04-15 
11:43:05.0 +0200
@@ -1,4 +1,4 @@
-! {dg_do run }
+! { dg_do run }
 !
 ! Tests the fix for PR67674
 !
--- ../_clean/gcc/testsuite/gfortran.dg/generic_29.f90  2015-05-19 
11:22:18.0 +0200
+++ gcc/testsuite/gfortran.dg/generic_29.f902017-04-15 11:44:48.0 
+0200
@@ -1,4 +1,4 @@
-! { dg-do compile}
+! { dg-do compile }
 ! PR fortran/66057
 !
 ! Original code from Gerhard Steinmetz
--- ../_clean/gcc/testsuite/gfortran.dg/pr41922.f90 2016-07-31 
04:06:39.0 +0200
+++ gcc/testsuite/gfortran.dg/pr41922.f90   2017-04-15 11:43:43.0 
+0200
@@ -1,4 +1,4 @@
-! { dg-do compile}
+! { dg-do compile }
 ! { dg-options -std=gnu }
   Subroutine RestoreR8Run()
   Implicit NONE
--- ../_clean/gcc/testsuite/gfortran.dg/pr70006.f90 2016-07-31 
03:47:24.0 +0200
+++ gcc/testsuite/gfortran.dg/pr70006.f90   2017-04-15 11:44:11.0 
+0200
@@ -1,4 +1,4 @@
-! { dg-do compile}
+! { dg-do compile }
 program test
print 1, 'string 1' ! { dg-error "FORMAT label 1" " " { target *-*-* } 3 }
print 1, 'string 2' ! { dg-error "FORMAT label 1" " " { target *-*-* } 4 }
--- ../_clean/gcc/testsuite/gfortran.dg/goacc/multi-clause.f90  2015-11-06 
06:40:12.0 +0100
+++ gcc/testsuite/gfortran.dg/goacc/multi-clause.f902017-04-15 
13:04:20.0 +0200
@@ -1,6 +1,6 @@
 ! Test if variable appearing in multiple clauses are errors.
 
-! { dg-compile }
+! { dg-do compile }
 
 program combined
   implicit none

Dominique

Re: [PATCH] Cleanup dg directives

2017-04-15 Thread Janus Weil
2017-04-15 16:46 GMT+02:00 Dominique d'Humières :
> I am planning to commit as obvious the following changes

Sure! But ...


> --- ../_clean/gcc/testsuite/gfortran.dg/deferred_character_3.f90
> 2015-11-15 15:12:11.0 +0100
> +++ gcc/testsuite/gfortran.dg/deferred_character_3.f90  2017-04-15 
> 11:43:05.0 +0200
> @@ -1,4 +1,4 @@
> -! {dg_do run }
> +! { dg_do run }
>  !

... this should certainly be a "dg-do" ?!?

Cheers,
Janus


Re: [PATCH] Cleanup dg directives

2017-04-15 Thread Dominique d'Humières

> Le 15 avr. 2017 à 16:56, Janus Weil  a écrit :
> 
> 2017-04-15 16:46 GMT+02:00 Dominique d'Humières :
>> I am planning to commit as obvious the following changes
> 
> Sure! But ...
> 
> 
>> --- ../_clean/gcc/testsuite/gfortran.dg/deferred_character_3.f90
>> 2015-11-15 15:12:11.0 +0100
>> +++ gcc/testsuite/gfortran.dg/deferred_character_3.f90  2017-04-15 
>> 11:43:05.0 +0200
>> @@ -1,4 +1,4 @@
>> -! {dg_do run }
>> +! { dg_do run }
>> !
> 
> ... this should certainly be a "dg-do" ?!?
> 
> Cheers,
> Janus

Good catch!-)

Thanks,

Dominique



Re: [PATCH, gfortran] Cleanup the submodule tests

2017-04-15 Thread Janus Weil
2017-04-15 15:57 GMT+02:00 Dominique d'Humières :
>
>> Le 15 avr. 2017 à 13:00, Janus Weil  a écrit :
>>
>> Hi Dominique,
>>
>> if I'm not mistaken, the cleanup of module file in the testsuite is
>> done automatically by now, right? Couldn't one do the same also for
>> submodules?
>>
>> Cheers,
>> Janus
>>
>
> This is indeed doable, but before I’ld like to improve the module cleanup 
> with the following patch

Yes, looks very useful to me (makes the regexps much more compact &
readable). In addition, couldn't one use \s for whitespace instead of
\[ \t\]   ?

I assume your igrep is just a copy of dejagnu's grep with an additional -nocase?

Cheers,
Janus



> --- ../_clean/gcc/testsuite/lib/fortran-modules.exp 2017-01-01 
> 17:38:58.0 +0100
> +++ gcc/testsuite/lib/fortran-modules.exp   2017-01-03 09:19:02.0 
> +0100
> @@ -79,10 +79,11 @@ proc list-module-names { files } {
>
>  proc list-module-names-1 { file } {
>  set result {}
> -set tmp [grep $file "^\[ \t\]*((#)?\[ 
> \t\]*include|\[mM\]\[oO\]\[dD\]\[uU\]\[lL\]\[eE\](?!\[ 
> \t\]+\[pP\]\[rR\]\[oO\]\[cC\]\[eE\]\[dD\]\[uU\]\[rR\]\[eE\]\[ \t\]+))\[ 
> \t\]+.*" line]
> +if {[file isdirectory $file]} {return}
> +set tmp [igrep $file "^\[ \t\]*((#)?\[ \t\]*include|module(?!\[ 
> \t\]+procedure\[ \t\]+))\[ \t\]+.*" line]
>  if {![string match "" $tmp]} {
> foreach i $tmp {
> -   regexp "(\[0-9\]+)\[ \t\]+(?:(?:#)?\[ \t\]*include\[ 
> \t\]+)\[\"\](\[^\"\]*)\[\"\]" $i dummy lineno include_file
> +   regexp -nocase "(\[0-9\]+)\[ \t\]+(?:(?:#)?\[ \t\]*include\[ 
> \t\]+)\[\"\'\](\[^\"\'\]*)\[\"\'\]" $i dummy lineno include_file
> if {[info exists include_file]} {
> set dir [file dirname $file]
> set inc "$dir/$include_file"
> @@ -99,7 +100,7 @@ proc list-module-names-1 { file } {
> }
> continue
> }
> -   regexp "(\[0-9\]+)\[ 
> \t\]+(?:(\[mM\]\[oO\]\[dD\]\[uU\]\[lL\]\[eE\]\[ 
> \t\]+(?!\[pP\]\[rR\]\[oO\]\[cC\]\[eE\]\[dD\]\[uU\]\[rR\]\[eE\]\[ \t\]+)))(\[^ 
> \t;\]*)" $i i lineno keyword mod
> +   regexp -nocase "(\[0-9\]+)\[ \t\]+(?:(\module\[ 
> \t\]+(?!procedure\[ \t\]+)))(\[^ \t;\]*)" $i i lineno keyword mod
> if {![info exists lineno]} {
> continue
> }
> @@ -111,3 +112,54 @@ proc list-module-names-1 { file } {
>  }
>  return $result
>  }
> +
> +# Looks for case insensitive occurrences of a string in a file.
> +# return:list of lines that matched or NULL if none match.
> +# args:  first arg is the filename,
> +#second is the pattern,
> +#third are any options.
> +# Options: line  - puts line numbers of match in list
> +#
> +proc igrep { args } {
> +
> +set file [lindex $args 0]
> +set pattern [lindex $args 1]
> +
> +verbose "Grepping $file for the pattern \"$pattern\"" 3
> +
> +set argc [llength $args]
> +if { $argc > 2 } {
> +for { set i 2 } { $i < $argc } { incr i } {
> +append options [lindex $args $i]
> +append options " "
> +}
> +} else {
> +set options ""
> +}
> +
> +set i 0
> +set fd [open $file r]
> +while { [gets $fd cur_line]>=0 } {
> +incr i
> +if {[regexp -nocase -- "$pattern" $cur_line match]} {
> +if {![string match "" $options]} {
> +foreach opt $options {
> +switch $opt {
> +"line" {
> +lappend grep_out [concat $i $match]
> +}
> +}
> +}
> +} else {
> +lappend grep_out $match
> +}
> +}
> +}
> +close $fd
> +unset fd
> +unset i
> +if {![info exists grep_out]} {
> +set grep_out ""
> +}
> +return $grep_out
> +}
>
> Dominique
>


[PATCH 0/7] [D] libiberty: D symbol demangling updates.

2017-04-15 Thread Iain Buclaw
Hi,

This patch series includes a new addition to the current iteration of
the D language, plus many fixes surrounding the clarification of
certain parts of the D ABI specification.

---

Iain Buclaw (7):
  [D] libiberty: Add support for demangling scope attributes.
  [D] libiberty: Add support for demangling template constraints.
  [D] libiberty: Recognize anonymous symbol names.
  [D] libiberty: Remove wrongly spec'd mangle rule for encoded integers.
  [D] libiberty: Fixes for demangling qualified symbol names.
  [D] libiberty: Fixes for decoding numbers.
  [D] libiberty: Refactor and add tests for decoding hexdigits.


 libiberty/ChangeLog |  51 +++
 libiberty/d-demangle.c  | 448
+++--
 libiberty/testsuite/d-demangle-expected | 244 ---
 3 files changed, 521 insertions(+), 222 deletions(-)


[PATCH 1/7] [D] libiberty: Add support for demangling scope attributes.

2017-04-15 Thread Iain Buclaw
The next version of D adds a new `scope' function attribute.  This
adds support for demangling them.

---
commit 15a0592cf6403fccbf43f3c7dc44f7d22c0f3dfa
Author: Iain Buclaw 
Date:   Sat Apr 15 11:15:41 2017 +0200

libiberty/ChangeLog:

2017-04-15  Iain Buclaw  

	* d-demangle.c (dlang_attributes): Handle scope attributes.
	* testsuite/d-demangle-expected: Add tests.

diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 12457f0..af7c63d 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -327,6 +327,10 @@ dlang_attributes (string *decl, const char *mangled)
 	  mangled++;
 	  string_append (decl, "return ");
 	  continue;
+	case 'l': /* scope */
+	  mangled++;
+	  string_append (decl, "scope ");
+	  continue;
 
 	default: /* unknown attribute */
 	  return NULL;
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index 04d39f4..57f7c52 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -330,6 +330,10 @@ _D8demangle4testFNkaZv
 demangle.test(return char)
 #
 --format=dlang
+_D8demangle4testFNlaZv
+demangle.test(char)
+#
+--format=dlang
 _D8demangle4testFaXv
 demangle.test(char...)
 #
@@ -478,6 +482,26 @@ _D8demangle4testFNjNkDFNjZaZv
 demangle.test(return char() return delegate)
 #
 --format=dlang
+_D8demangle4testFNlDFZaZv
+demangle.test(char() delegate)
+#
+--format=dlang
+_D8demangle4testFMDFZaZv
+demangle.test(scope char() delegate)
+#
+--format=dlang
+_D8demangle4testFDFNlZaZv
+demangle.test(char() scope delegate)
+#
+--format=dlang
+_D8demangle4testFMDFNlZaZv
+demangle.test(scope char() scope delegate)
+#
+--format=dlang
+_D8demangle4testFNlMDFNlZaZv
+demangle.test(scope char() scope delegate)
+#
+--format=dlang
 _D8demangle4testFPFNaZaZv
 demangle.test(char() pure function)
 #
@@ -534,6 +558,26 @@ _D8demangle4testFNjNkPFNjZaZv
 demangle.test(return char() return function)
 #
 --format=dlang
+_D8demangle4testFNlPFZaZv
+demangle.test(char() function)
+#
+--format=dlang
+_D8demangle4testFMPFZaZv
+demangle.test(scope char() function)
+#
+--format=dlang
+_D8demangle4testFPFNlZaZv
+demangle.test(char() scope function)
+#
+--format=dlang
+_D8demangle4testFMPFNlZaZv
+demangle.test(scope char() scope function)
+#
+--format=dlang
+_D8demangle4testFNlMPFNlZaZv
+demangle.test(scope char() scope function)
+#
+--format=dlang
 _D8demangle4test6__initZ
 demangle.test.init$
 #


[PATCH 2/7] [D] libiberty: Add support for demangling template constraints.

2017-04-15 Thread Iain Buclaw
This implements a previously an undocumented part of the D ABI spec,
where symbols instantiated inside a template constraint are given a
different prefix.  In practise however this should never be
encountered, as such instantiations are normally considered
speculative, and so never make it to object code.

---
commit 9f3fa1f5842dc317b0aaf2f9aa159548c9b7a7f7
Author: Iain Buclaw 
Date:   Sat Apr 15 11:29:35 2017 +0200

libiberty/ChangeLog:

2017-04-15  Iain Buclaw  

	* d-demangle.c (dlang_identifier): Handle template constraint symbols.
	(dlang_parse_template): Only advance if template symbol prefix is
	followed by a digit.
	* testsuite/d-demangle-expected: Add tests.

diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index af7c63d..74dde9d 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -769,14 +769,9 @@ dlang_identifier (string *decl, const char *mangled,
   mangled = endptr;
 
   /* May be a template instance.  */
-  if (len >= 5 && strncmp (mangled, "__T", 3) == 0)
-	{
-	  /* Template symbol.  */
-	  if (ISDIGIT (mangled[3]) && mangled[3] != '0')
-	return dlang_parse_template (decl, mangled, len);
-
-	  return NULL;
-	}
+  if (len >= 5 && mangled[0] == '_' && mangled[1] == '_'
+	  && (mangled[2] == 'T' || mangled[2] == 'U'))
+	return dlang_parse_template (decl, mangled, len);
 
   switch (len)
 	{
@@ -1541,11 +1536,14 @@ dlang_parse_template (string *decl, const char *mangled, long len)
 
 	TemplateInstanceName:
 	Number __T LName TemplateArgs Z
+	Number __U LName TemplateArgs Z
 		   ^
  The start pointer should be at the above location, and LEN should be
  the value of the decoded number.
*/
-  if (strncmp (mangled, "__T", 3) != 0)
+
+  /* Template symbol.  */
+  if (!ISDIGIT (mangled[3]) || mangled[3] == '0')
 return NULL;
 
   mangled += 3;
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index 57f7c52..6725684 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -650,6 +650,10 @@ _D8demangle9__T4testZv
 demangle.test!()
 #
 --format=dlang
+_D8demangle9__U4testZv
+demangle.test!()
+#
+--format=dlang
 _D8demangle11__T4testTaZv
 demangle.test!(char)
 #


[PATCH 3/7] [D] libiberty: Recognize anonymous symbols names.

2017-04-15 Thread Iain Buclaw
This implements another previously undocumented part of the D ABI
spec, where symbols with no name are always encoded into the mangled
name.

SymbolName:
LName
TemplateInstanceName
0 // anonymous symbols

This has never really been a problem, as strtol() kindly jumps over
any leading zeros in the number it is parsing.  However this change
makes it so they are at least explicitly skipped over, rather than
silently ignored.

---
commit 6ffcb4ce75e471304960c97bec596c89e26894f8
Author: Iain Buclaw 
Date:   Sat Apr 15 11:32:07 2017 +0200

libiberty/ChangeLog:

2017-04-15  Iain Buclaw  

	* d-demangle.c (dlang_parse_symbol): Skip over anonymous symbols.
	* testsuite/d-demangle-expected: Add tests.

diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 74dde9d..533653f 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -1362,6 +1362,10 @@ dlang_parse_symbol (string *decl, const char *mangled,
   if (n++)
 	string_append (decl, ".");
 
+  /* Skip over anonymous symbols.  */
+  while (*mangled == '0')
+	mangled++;
+
   mangled = dlang_identifier (decl, mangled, kind);
 
   if (mangled && dlang_call_convention_p (mangled))
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index 6725684..530e0e6 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -929,6 +929,14 @@ demangle.test(char() delegate shared inout)
 _D8demangle4testFDONgxFZaZv
 demangle.test(char() delegate shared inout const)
 #
+--format=dlang
+_D8demangle004testFaZv
+demangle.test(char)
+#
+--format=dlang
+_D8demangle4testFaZv
+demangle.test(char)
+#
 # Unittests
 #
 --format=dlang


[PATCH 4/7] [D] libiberty: Remove wrongly spec'd mangle rule for encoded integers.

2017-04-15 Thread Iain Buclaw
This updates the implementation to reflect a part of the D ABI spec
that has been removed.  There should never be a bare integer value
encoded into a template argument list.  Integers are always prefixed
by `i' if they are positive or `N' if they are negative.

Have verified this indeed is the case using the code below, and
updated all coverage tests to match the compiler.

module demangle;

template test(alias T)
{
void test() { auto t = T; }
}

pragma(msg, (test!(cast(byte)123)).mangleof);
pragma(msg, (test!(cast(int)123)).mangleof);
pragma(msg, (test!(cast(short)123)).mangleof);
pragma(msg, (test!(cast(ubyte)123)).mangleof);
pragma(msg, (test!(cast(uint)123)).mangleof);
pragma(msg, (test!(cast(ushort)123)).mangleof);
pragma(msg, (test!(cast(long)123)).mangleof);
pragma(msg, (test!(cast(ulong)123)).mangleof);
pragma(msg, (test!(true)).mangleof);
pragma(msg, (test!(false)).mangleof);
pragma(msg, (test!('\x0a')).mangleof);
pragma(msg, (test!(' ')).mangleof);
pragma(msg, (test!('A')).mangleof);
pragma(msg, (test!('~')).mangleof);
pragma(msg, (test!('\u03e8')).mangleof);
pragma(msg, (test!('\U000186a0')).mangleof);

---
commit 30ff1ef529c4711ab08e168c79e4971cd44f17f4
Author: Iain Buclaw 
Date:   Sat Apr 15 11:35:35 2017 +0200

libiberty/ChangeLog:

2017-04-15  Iain Buclaw  

	* d-demangle.c (dlang_value): Remove fallthrough and cases for digits.
	* testsuite/d-demangle-expected: Update integer value tests.

diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 533653f..71be8fb 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -1242,9 +1242,6 @@ dlang_value (string *decl, const char *mangled, const char *name, char type)
   mangled++;
   if (*mangled < '0' || *mangled > '9')
 	return NULL;
-  /* Fall through */
-case '0': case '1': case '2': case '3': case '4':
-case '5': case '6': case '7': case '8': case '9':
   mangled = dlang_parse_integer (decl, mangled, type);
   break;
 
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index 530e0e6..0692729 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -698,35 +698,35 @@ _D8demangle13__T4testVPinZv
 demangle.test!(null)
 #
 --format=dlang
-_D8demangle14__T4testVg123Zv
+_D8demangle15__T4testVgi123Zv
 demangle.test!(123)
 #
 --format=dlang
-_D8demangle14__T4testVi123Zv
+_D8demangle15__T4testVii123Zv
 demangle.test!(123)
 #
 --format=dlang
-_D8demangle14__T4testVs123Zv
+_D8demangle15__T4testVsi123Zv
 demangle.test!(123)
 #
 --format=dlang
-_D8demangle14__T4testVh123Zv
+_D8demangle15__T4testVhi123Zv
 demangle.test!(123u)
 #
 --format=dlang
-_D8demangle14__T4testVk123Zv
+_D8demangle15__T4testVki123Zv
 demangle.test!(123u)
 #
 --format=dlang
-_D8demangle14__T4testVt123Zv
+_D8demangle15__T4testVti123Zv
 demangle.test!(123u)
 #
 --format=dlang
-_D8demangle14__T4testVl123Zv
+_D8demangle15__T4testVli123Zv
 demangle.test!(123L)
 #
 --format=dlang
-_D8demangle14__T4testVm123Zv
+_D8demangle15__T4testVmi123Zv
 demangle.test!(123uL)
 #
 --format=dlang
@@ -746,35 +746,35 @@ _D8demangle15__T4testVmN123Zv
 demangle.test!(-123uL)
 #
 --format=dlang
-_D8demangle12__T4testVb1Zv
+_D8demangle13__T4testVbi1Zv
 demangle.test!(true)
 #
 --format=dlang
-_D8demangle12__T4testVb0Zv
+_D8demangle13__T4testVbi0Zv
 demangle.test!(false)
 #
 --format=dlang
-_D8demangle13__T4testVa10Zv
+_D8demangle14__T4testVai10Zv
 demangle.test!('\x0a')
 #
 --format=dlang
-_D8demangle13__T4testVa32Zv
+_D8demangle14__T4testVai32Zv
 demangle.test!(' ')
 #
 --format=dlang
-_D8demangle13__T4testVa65Zv
+_D8demangle14__T4testVai65Zv
 demangle.test!('A')
 #
 --format=dlang
-_D8demangle14__T4testVa126Zv
+_D8demangle15__T4testVai126Zv
 demangle.test!('~')
 #
 --format=dlang
-_D8demangle15__T4testVu1000Zv
+_D8demangle16__T4testVui1000Zv
 demangle.test!('\u03e8')
 #
 --format=dlang
-_D8demangle17__T4testVw10Zv
+_D8demangle18__T4testVwi10Zv
 demangle.test!('\U000186a0')
 #
 --format=dlang
@@ -1076,7 +1076,7 @@ _D8demangle20__T2fnVAiA4i1i2i3i4Z2fnFZv
 demangle.fn!([1, 2, 3, 4]).fn()
 #
 --format=dlang
-_D8demangle10__T2fnVi1Z2fnFZv
+_D8demangle11__T2fnVii1Z2fnFZv
 demangle.fn!(1).fn()
 #
 --format=dlang
@@ -1104,7 +1104,7 @@ _D8demangle2fnFNgiZNgi
 demangle.fn(inout(int))
 #
 --format=dlang
-_D8demangle29__T2fnVa97Va9Va0Vu257Vw65537Z2fnFZv
+_D8demangle34__T2fnVai97Vai9Vai0Vui257Vwi65537Z2fnFZv
 demangle.fn!('a', '\x09', '\x00', '\u0101', '\U00010001').fn()
 #
 --format=dlang


[PATCH 5/7] [D] libiberty: Fixes for demangling qualified symbol names

2017-04-15 Thread Iain Buclaw
This patch removes `dlang_parse_symbol', and replaces it with
`dlang_parse_qualified' and `dlang_parse_mangle'.  All callers have
been updated to reflect as to whether we expect either a `MangleName'
or `QualifiedName' to be the next token we encounter, which matches
many clarifications that have been made in the specification.

This also removes the special case of matching `V' - or encoded
extern(Pascal) functions - and instead uses a more generic approach in
that if a `CallConvention' symbol was encountered whilst consuming
`QualifiedName', it *must* be followed by another `QualifiedName',
otherwise we've reached the end of the matched rule.  It still defeats
the purpose of the aiming to having a context-free grammar, but at
least it's a little less evil than before.

---
commit 8701a7e99b9146719881adcf019ecbebe836b755
Author: Iain Buclaw 
Date:   Sat Apr 15 11:54:27 2017 +0200

libiberty/ChangeLog:

2017-04-15  Iain Buclaw  

	* d-demangle.c (dlang_parse_symbol): Remove function.
	(dlang_parse_qualified): New function.
	(dlang_parse_mangle): New function.
	(dlang_type): Update to call dlang_parse_qualified.
	(dlang_identifier): Update to call either dlang_parse_qualified or
	dlang_parse_mangle.
	(dlang_type_modifier_p): Remove function.
	(dlang_call_convention_p): Don't allow for type modifiers in mangle.
	(dlang_template_args): Update to call dlang_identifier.
	(dlang_demangle): Update to call dlang_parse_mangle.
	* testsuite/d-demangle-expected: Add tests.

diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 71be8fb..7e9d5bf 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -186,7 +186,10 @@ static const char *dlang_type (string *, const char *);
 
 static const char *dlang_value (string *, const char *, const char *, char);
 
-static const char *dlang_parse_symbol (string *, const char *,
+static const char *dlang_parse_qualified (string *, const char *,
+	  enum dlang_symbol_kinds);
+
+static const char *dlang_parse_mangle (string *, const char *,
    enum dlang_symbol_kinds);
 
 static const char *dlang_parse_tuple (string *, const char *);
@@ -561,7 +564,7 @@ dlang_type (string *decl, const char *mangled)
 case 'E': /* enum T */
 case 'T': /* typedef T */
   mangled++;
-  return dlang_parse_symbol (decl, mangled, dlang_type_name);
+  return dlang_parse_qualified (decl, mangled, dlang_type_name);
 case 'D': /* delegate T */
 {
   string mods;
@@ -743,12 +746,10 @@ dlang_identifier (string *decl, const char *mangled,
 	  /* Check whether template parameter is a function with a valid
 	 return type or an untyped identifier.  */
 	  if (ISDIGIT (*mangled))
-	mangled = dlang_parse_symbol (decl, mangled, dlang_template_ident);
+	mangled = dlang_parse_qualified (decl, mangled,
+	 dlang_template_ident);
 	  else if (strncmp (mangled, "_D", 2) == 0)
-	{
-	  mangled += 2;
-	  mangled = dlang_parse_symbol (decl, mangled, dlang_function);
-	}
+	mangled = dlang_parse_mangle (decl, mangled, dlang_function);
 
 	  /* Check for name length mismatch.  */
 	  if (mangled && (mangled - pend) == psize)
@@ -1292,36 +1293,6 @@ dlang_value (string *decl, const char *mangled, const char *name, char type)
   return mangled;
 }
 
-/* Extract the type modifiers from MANGLED and return the string
-   length that it consumes in MANGLED on success or 0 on failure.  */
-static int
-dlang_type_modifier_p (const char *mangled)
-{
-  int i;
-
-  switch (*mangled)
-{
-case 'x': case 'y':
-  return 1;
-
-case 'O':
-  mangled++;
-  i = dlang_type_modifier_p (mangled);
-  return i + 1;
-
-case 'N':
-  mangled++;
-  if (*mangled == 'g')
-	{
-	  mangled++;
-	  i = dlang_type_modifier_p (mangled);
-	  return i + 2;
-	}
-}
-
-  return 0;
-}
-
 /* Extract the function calling convention from MANGLED and
return 1 on success or 0 on failure.  */
 static int
@@ -1329,11 +1300,7 @@ dlang_call_convention_p (const char *mangled)
 {
   /* Prefix for functions needing 'this' */
   if (*mangled == 'M')
-{
-  mangled++;
-  /* Also skip over any type modifiers.  */
-  mangled += dlang_type_modifier_p (mangled);
-}
+mangled++;
 
   switch (*mangled)
 {
@@ -1349,10 +1316,94 @@ dlang_call_convention_p (const char *mangled)
 /* Extract and demangle the symbol in MANGLED and append it to DECL.
Returns the remaining signature on success or NULL on failure.  */
 static const char *
-dlang_parse_symbol (string *decl, const char *mangled,
+dlang_parse_mangle (string *decl, const char *mangled,
 		enum dlang_symbol_kinds kind)
 {
-  int saved;
+  /* A D mangled symbol is comprised of both scope and type information.
+
+	MangleName:
+	_D QualifiedName Type
+	_D QualifiedName M Type
+	_D QualifiedName Z
+	^
+ The caller should have guaranteed that the start pointer is at the
+ abov

[PATCH 6/7] [D] libiberty: Fixes for decoding numbers.

2017-04-15 Thread Iain Buclaw
This fixes two main problems found in the use of strtol().  First that
it returns `0' if nothing is decoded, and none of the callers checked
whether nothing was consumed.  Second that it just returns  `LONG_MAX'
on overflow.  Rather than updating each individual call site, have
solved [1] by moving all uses into a new function that validates the
next character is a digit, and [2] by removing the import of `strtol'
and doing the decoding ourselves with the explicit check for overflow.

Added many coverage tests, many of which unearthed hidden segfaults.

---
commit 87041417fdf6911b5112c4c68b324577202fa2d0
Author: Iain Buclaw 
Date:   Sat Apr 15 12:02:10 2017 +0200

libiberty/ChangeLog:

2017-04-15  Iain Buclaw  

	* d-demangle.c (strtol): Remove declaration.
	Updated all callers to use dlang_number.
	(dlang_number): New function.
	(dlang_value): Moved check for ISDIGIT into dlang_parse_integer.
	* testsuite/d-demangle-expected: Add tests.

diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 7e9d5bf..84a7186 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -26,9 +26,7 @@ You should have received a copy of the GNU Library General Public
 License along with libiberty; see the file COPYING.LIB.
 If not, see .  */
 
-/* This file exports one function; dlang_demangle.
-
-   This file imports strtol for decoding mangled literals.  */
+/* This file exports one function; dlang_demangle.  */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -42,8 +40,6 @@ If not, see .  */
 
 #ifdef HAVE_STDLIB_H
 #include 
-#else
-extern long strtol (const char *nptr, char **endptr, int base);
 #endif
 
 #include 
@@ -197,6 +193,36 @@ static const char *dlang_parse_tuple (string *, const char *);
 static const char *dlang_parse_template (string *, const char *, long);
 
 
+/* Extract the number from MANGLED, and assign the result to RET.
+   Return the remaining string on success or NULL on failure.  */
+static const char *
+dlang_number (const char *mangled, long *ret)
+{
+  /* Return NULL if trying to extract something that isn't a digit.  */
+  if (mangled == NULL || !ISDIGIT (*mangled))
+return NULL;
+
+  *ret = 0;
+
+  while (ISDIGIT (*mangled))
+{
+  *ret *= 10;
+
+  /* If an overflow occured when multiplying by ten, the result
+	 will not be a multiple of ten.  */
+  if ((*ret % 10) != 0)
+	return NULL;
+
+  *ret += mangled[0] - '0';
+  mangled++;
+}
+
+  if (*mangled == '\0' || *ret < 0)
+return NULL;
+
+  return mangled;
+}
+
 /* Demangle the calling convention from MANGLED and append it to DECL.
Return the remaining string on success or NULL on failure.  */
 static const char *
@@ -709,15 +735,10 @@ static const char *
 dlang_identifier (string *decl, const char *mangled,
 		  enum dlang_symbol_kinds kind)
 {
-  char *endptr;
   long len;
+  const char *endptr = dlang_number (mangled, &len);
 
-  if (mangled == NULL || *mangled == '\0')
-return NULL;
-
-  len = strtol (mangled, &endptr, 10);
-
-  if (endptr == NULL || len <= 0)
+  if (endptr == NULL || len == 0)
 return NULL;
 
   /* In template parameter symbols, the first character of the mangled
@@ -726,7 +747,7 @@ dlang_identifier (string *decl, const char *mangled,
   if (kind == dlang_template_param)
 {
   long psize = len;
-  char *pend;
+  const char *pend;
   int saved = string_length (decl);
 
   /* Work backwards until a match is found.  */
@@ -871,10 +892,10 @@ dlang_parse_integer (string *decl, const char *mangled, char type)
   char value[10];
   int pos = 10;
   int width = 0;
-  char *endptr;
-  long val = strtol (mangled, &endptr, 10);
+  long val;
 
-  if (endptr == NULL || val < 0)
+  mangled = dlang_number (mangled, &val);
+  if (mangled == NULL)
 	return NULL;
 
   string_append (decl, "'");
@@ -923,19 +944,17 @@ dlang_parse_integer (string *decl, const char *mangled, char type)
 	  string_appendn (decl, &(value[pos]), 10 - pos);
 	}
   string_append (decl, "'");
-  mangled = endptr;
 }
   else if (type == 'b')
 {
   /* Parse boolean value.  */
-  char *endptr;
-  long val = strtol (mangled, &endptr, 10);
+  long val;
 
-  if (endptr == NULL || val < 0)
+  mangled = dlang_number (mangled, &val);
+  if (mangled == NULL)
 	return NULL;
 
   string_append (decl, val ? "true" : "false");
-  mangled = endptr;
 }
   else
 {
@@ -943,6 +962,9 @@ dlang_parse_integer (string *decl, const char *mangled, char type)
   const char *numptr = mangled;
   size_t num = 0;
 
+  if (! ISDIGIT (*mangled))
+	return NULL;
+
   while (ISDIGIT (*mangled))
 	{
 	  num++;
@@ -1070,17 +1092,11 @@ static const char *
 dlang_parse_string (string *decl, const char *mangled)
 {
   char type = *mangled;
-  char *endptr;
   long len;
 
   mangled++;
-  len = strtol (mangled, 

[PATCH 7/7] [D] libiberty: Refactor and add tests for decoding hexdigits.

2017-04-15 Thread Iain Buclaw
Similar to the patch for decoding numbers, puts the handling of
character decoding into a designated function with the same style
caller interface.  Removes one nested level and decoding logic from
`dlang_parse_string'.

Added some more tests, which brings overall coverage of this code to
all but 3 lines, two of which I have checked and are genuinely
unreachable.

---
commit de5523a4ff9d755940fc7dc5beadb65f0aafd0df
Author: Iain Buclaw 
Date:   Sat Apr 15 13:10:43 2017 +0200

libiberty/ChangeLog:

2017-04-15  Iain Buclaw  

	* d-demangle.c (dlang_hexdigit): New function.
	(ascii2hex): Remove function.
	(dlang_parse_string): Update to call dlang_hexdigit.
	* testsuite/d-demangle-expected: Add tests.

diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 84a7186..ed97d2d 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -223,6 +223,34 @@ dlang_number (const char *mangled, long *ret)
   return mangled;
 }
 
+/* Extract the hex-digit from MANGLED, and assign the result to RET.
+   Return the remaining string on success or NULL on failure.  */
+static const char *
+dlang_hexdigit (const char *mangled, char *ret)
+{
+  char c;
+
+  /* Return NULL if trying to extract something that isn't a hexdigit.  */
+  if (mangled == NULL || !ISXDIGIT (mangled[0]) || !ISXDIGIT (mangled[1]))
+return NULL;
+
+  c = mangled[0];
+  if (!ISDIGIT (c))
+*ret = (c - (ISUPPER (c) ? 'A' : 'a') + 10);
+  else
+*ret = (c - '0');
+
+  c = mangled[1];
+  if (!ISDIGIT (c))
+*ret = (*ret << 4) | (c - (ISUPPER (c) ? 'A' : 'a') + 10);
+  else
+*ret = (*ret << 4) | (c - '0');
+
+  mangled += 2;
+
+  return mangled;
+}
+
 /* Demangle the calling convention from MANGLED and append it to DECL.
Return the remaining string on success or NULL on failure.  */
 static const char *
@@ -1070,22 +1098,6 @@ dlang_parse_real (string *decl, const char *mangled)
   return mangled;
 }
 
-/* Convert VAL from an ascii hexdigit to value.  */
-static char
-ascii2hex (char val)
-{
-  if (val >= 'a' && val <= 'f')
-return (val - 'a' + 10);
-
-  if (val >= 'A' && val <= 'F')
-return (val - 'A' + 10);
-
-  if (val >= '0' && val <= '9')
-return (val - '0');
-
-  return 0;
-}
-
 /* Extract the string value from MANGLED and append it to DECL.
Return the remaining string on success or NULL on failure.  */
 static const char *
@@ -1103,48 +1115,45 @@ dlang_parse_string (string *decl, const char *mangled)
   string_append (decl, "\"");
   while (len--)
 {
-  if (ISXDIGIT (mangled[0]) && ISXDIGIT (mangled[1]))
+  char val;
+  const char *endptr = dlang_hexdigit (mangled, &val);
+
+  if (endptr == NULL)
+	return NULL;
+
+  /* Sanitize white and non-printable characters.  */
+  switch (val)
 	{
-	  char a = ascii2hex (mangled[0]);
-	  char b = ascii2hex (mangled[1]);
-	  char val = (a << 4) | b;
+	case ' ':
+	  string_append (decl, " ");
+	  break;
+	case '\t':
+	  string_append (decl, "\\t");
+	  break;
+	case '\n':
+	  string_append (decl, "\\n");
+	  break;
+	case '\r':
+	  string_append (decl, "\\r");
+	  break;
+	case '\f':
+	  string_append (decl, "\\f");
+	  break;
+	case '\v':
+	  string_append (decl, "\\v");
+	  break;
 
-	  /* Sanitize white and non-printable characters.  */
-	  switch (val)
+	default:
+	  if (ISPRINT (val))
+	string_appendn (decl, &val, 1);
+	  else
 	{
-	case ' ':
-	  string_append (decl, " ");
-	  break;
-	case '\t':
-	  string_append (decl, "\\t");
-	  break;
-	case '\n':
-	  string_append (decl, "\\n");
-	  break;
-	case '\r':
-	  string_append (decl, "\\r");
-	  break;
-	case '\f':
-	  string_append (decl, "\\f");
-	  break;
-	case '\v':
-	  string_append (decl, "\\v");
-	  break;
-
-	default:
-	  if (ISPRINT (val))
-		string_appendn (decl, &val, 1);
-	  else
-		{
-		  string_append (decl, "\\x");
-		  string_appendn (decl, mangled, 2);
-		}
+	  string_append (decl, "\\x");
+	  string_appendn (decl, mangled, 2);
 	}
 	}
-  else
-	return NULL;
 
-  mangled += 2;
+  mangled = endptr;
 }
   string_append (decl, "\"");
 
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index 9fc1551..8c349fd 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -850,6 +850,14 @@ _D8demangle22__T4testVG3uw3_616263Zv
 demangle.test!("abc"w)
 #
 --format=dlang
+_D8demangle16__T4testVAyaa0_Zv
+demangle.test!("")
+#
+--format=dlang
+_D8demangle32__T4testVAyaa8_20090a0d0c0b00ffZv
+demangle.test!(" \t\n\r\f\v\x00\xff")
+#
+--format=dlang
 _D8demangle22__T4testVAiA4i1i2i3i4Zv
 demangle.test!([1, 2, 3, 4])
 #
@@ -1068,10 +1076,18 @@ _D15__T4testVfe0p1Zv
 _D15__T4testVfe0p1Zv
 #
 --format=dlang
+_D15__T4testVAyaa1_
+_D15__T4testVAyaa1_
+#
+--format=dlang
 _D16__T4testVAyaa0aZv
 _D16__T4testVAyaa0aZv
 #
 --format=dlang
+_D18__T4testVAyaa

Re: [PATCH, testsuite] Allow braces around relative line numbers

2017-04-15 Thread Mike Stump
On Apr 15, 2017, at 1:07 AM, Tom de Vries  wrote:
> I've attached two patches:
> 
> - second patch is the result of running the script.

> Second patch OK for stage4/stage1 trunk?

Ok.

> [ I'm not sure if the first patch is useful enough to commit to contrib. ]

Once the script it run, we shouldn't have to run it again.  So, I think it can 
live as a reference on the mailing list.

> 2017-04-14  Tom de Vries  
> 
>   * g++.dg/parse/error11.C: Remove braces around line number in dejagnu
> directive.
>   * g++.dg/parse/error3.C: Same.
>   * g++.old-deja/g++.pt/niklas01a.C: Same.
>   * gcc.dg/990506-0.c: Same.
>   * gcc.dg/cpp/19990413-1.c: Same.
>   * gcc.dg/cpp/pragma-1.c: Same.
>   * gcc.dg/cpp/pragma-2.c: Same.
>   * gcc.dg/m-un-2.c: Same.
>   * objc.dg/private-1.m: Same.



Re: [PATCH, gfortran] Cleanup the submodule tests

2017-04-15 Thread Dominique d'Humières

> Le 15 avr. 2017 à 17:13, Janus Weil  a écrit :
> 
> 2017-04-15 15:57 GMT+02:00 Dominique d'Humières :
>> 
>>> Le 15 avr. 2017 à 13:00, Janus Weil  a écrit :
>>> 
>>> Hi Dominique,
>>> 
>>> if I'm not mistaken, the cleanup of module file in the testsuite is
>>> done automatically by now, right? Couldn't one do the same also for
>>> submodules?
>>> 
>>> Cheers,
>>> Janus
>>> 
>> 
>> This is indeed doable, but before I’ld like to improve the module cleanup 
>> with the following patch
> 
> Yes, looks very useful to me (makes the regexps much more compact &
> readable). In addition, couldn't one use \s for whitespace instead of
> \[ \t\]   ?

I have posted what I have in my working tree. I’ll test the use of \s instead 
of \[ \t\] . Is it really portable?
> 
> 
> I assume your igrep is just a copy of dejagnu's grep with an additional 
> -nocase?

Yes!

> Cheers,
> Janus

Dominique



Re: [PATCH, gfortran] Cleanup the submodule tests

2017-04-15 Thread Janus Weil
2017-04-15 17:54 GMT+02:00 Dominique d'Humières :
>>> This is indeed doable, but before I’ld like to improve the module cleanup 
>>> with the following patch
>>
>> Yes, looks very useful to me (makes the regexps much more compact &
>> readable). In addition, couldn't one use \s for whitespace instead of
>> \[ \t\]   ?
>
> I have posted what I have in my working tree. I’ll test the use of \s instead 
> of \[ \t\] . Is it really portable?

Not sure. But at least some of the other files in gcc/testsuite/lib
seem to use \s as well (e.g. gcc-dg.exp).


>> I assume your igrep is just a copy of dejagnu's grep with an additional 
>> -nocase?
>
> Yes!

Ok to commit  from my side, if you have tested that it works properly.

Cheers,
Janus


Re: [PATCH] Cleanup dg directives

2017-04-15 Thread Dominique d'Humières
Committed as revision r246940.

Dominique

> Le 15 avr. 2017 à 16:56, Janus Weil  a écrit :
> 
> 2017-04-15 16:46 GMT+02:00 Dominique d'Humières :
>> I am planning to commit as obvious the following changes
> 
> Sure! But ...
> 
> 
>> --- ../_clean/gcc/testsuite/gfortran.dg/deferred_character_3.f90
>> 2015-11-15 15:12:11.0 +0100
>> +++ gcc/testsuite/gfortran.dg/deferred_character_3.f90  2017-04-15 
>> 11:43:05.0 +0200
>> @@ -1,4 +1,4 @@
>> -! {dg_do run }
>> +! { dg_do run }
>> !
> 
> ... this should certainly be a "dg-do" ?!?
> 
> Cheers,
> Janus



[PATCH, testsuite]: Fix some more dg-do directives

2017-04-15 Thread Uros Bizjak
2017-04-15  Uros Bizjak  

* gcc.dg/pr54669.c: Fix dg-do directive.
* gcc.dg/pr78582.c: Ditto.
* gcc.dg/pr80020.c: Ditto.
* gcc.dg/torture/pr57993-2.cpp: Ditto.
* gcc.dg/tree-ssa/builtin-sprintf-3.c: Ditto.
* gcc.dg/tree-ssa/builtin-sprintf-4.c: Ditto.
* gcc.dg/tree-ssa/builtin-sprintf-5.c: Ditto.
* gcc.dg/tree-ssa/builtin-sprintf-6.c: Ditto.
* gcc.dg/tree-ssa/builtin-sprintf-warn-5.c: Ditto.
* gcc.dg/tree-ssa/pr79327-2.c: Ditto.
* gcc.dg/tree-ssa/pr79352.c: Ditto.
* gcc.dg/tree-ssa/pr79376.c: Ditto.
* gcc.dg/tree-ssa/pr79691.c: Ditto.

Tested on x86_64-linux-gnu {-m32} and committed to mainline SVN.

Uros.
Index: gcc.dg/pr54669.c
===
--- gcc.dg/pr54669.c(revision 246843)
+++ gcc.dg/pr54669.c(working copy)
@@ -1,7 +1,7 @@
 /* PR tree-optimization/54669 */
 /* Testcase by Zdenek Sojka  */
 
-/* { dg-compile } */
+/* { dg-do compile } */
 /* { dg-options "-O2 -fexceptions -fnon-call-exceptions" } */
 
 int a[10];
Index: gcc.dg/pr78582.c
===
--- gcc.dg/pr78582.c(revision 246843)
+++ gcc.dg/pr78582.c(working copy)
@@ -1,6 +1,6 @@
 /* PR target/78582. */
 /* { dg-options "-fprofile-generate" } */
-/* { dg-compile } */
+/* { dg-do compile } */
 
 #include 
 
Index: gcc.dg/pr80020.c
===
--- gcc.dg/pr80020.c(revision 246843)
+++ gcc.dg/pr80020.c(working copy)
@@ -1,5 +1,5 @@
 /* PR middle-end/80020 - gcc confused about aligned_alloc argument order
-   { dg-compile }
+   { dg-do compile }
{ dg-options "-O2 -Wall -fdump-tree-optimized" } */
 
 void sink (void*);
Index: gcc.dg/torture/pr57993-2.cpp
===
--- gcc.dg/torture/pr57993-2.cpp(revision 246843)
+++ gcc.dg/torture/pr57993-2.cpp(working copy)
@@ -1,5 +1,5 @@
 /* This ICEd due to an incomplete fix for PR57993.  */
-/* { dg-compile } */
+/* { dg-do compile } */
 
 extern "C"
 {
Index: gcc.dg/tree-ssa/builtin-sprintf-3.c
===
--- gcc.dg/tree-ssa/builtin-sprintf-3.c (revision 246843)
+++ gcc.dg/tree-ssa/builtin-sprintf-3.c (working copy)
@@ -2,7 +2,7 @@
Test case derived from the one submitted in the bug.  It verifies
that the sprintf return value (or value range) optimization is not
performed for an unknown string.  */
-/* { dg-compile } */
+/* { dg-do compile } */
 /* { dg-options "-O2 -Wall -Werror -fdump-tree-optimized 
-fprintf-return-value" } */
 
 #define INT_MAX   __INT_MAX__
Index: gcc.dg/tree-ssa/builtin-sprintf-4.c
===
--- gcc.dg/tree-ssa/builtin-sprintf-4.c (revision 246843)
+++ gcc.dg/tree-ssa/builtin-sprintf-4.c (working copy)
@@ -2,7 +2,7 @@
gimple-ssa-sprintf.c:214
Disable warnings to exercise code paths through the pass that may
not be exercised when the -Wformat-overflow option is in effect.  */
-/* { dg-compile }
+/* { dg-do compile }
{ dg-options "-O2 -fdump-tree-optimized -w" } */
 
 
Index: gcc.dg/tree-ssa/builtin-sprintf-5.c
===
--- gcc.dg/tree-ssa/builtin-sprintf-5.c (revision 246843)
+++ gcc.dg/tree-ssa/builtin-sprintf-5.c (working copy)
@@ -1,6 +1,6 @@
 /* PR middle-end/78476 - snprintf(0, 0, ...) with known arguments not
optimized away
-   { dg-compile }
+   { dg-do compile }
{ dg-options "-O2 -fdump-tree-optimized" }
{ dg-require-effective-target int32plus } */
 
Index: gcc.dg/tree-ssa/builtin-sprintf-6.c
===
--- gcc.dg/tree-ssa/builtin-sprintf-6.c (revision 246843)
+++ gcc.dg/tree-ssa/builtin-sprintf-6.c (working copy)
@@ -4,7 +4,7 @@
A negative test complementing builtin-sprintf-5.c to verify that calls
to the function that do not return a constant are not optimized away.
Test also verifies that unknown directives prevent the optimization.
-   { dg-compile }
+   { dg-do compile }
{ dg-options "-O2 -Wformat -fdump-tree-optimized" }
{ dg-require-effective-target int32plus } */
 
Index: gcc.dg/tree-ssa/builtin-sprintf-warn-5.c
===
--- gcc.dg/tree-ssa/builtin-sprintf-warn-5.c(revision 246843)
+++ gcc.dg/tree-ssa/builtin-sprintf-warn-5.c(working copy)
@@ -1,8 +1,7 @@
 /* PR bootstrap/77676 - powerpc64 and powerpc64le stage2 bootstrap fail
Test case from comment 6 on the bug.  */
-/* { dg-compile } */
+/* { dg-do compile } */
 /* { dg-options "-Wall -Werror" } */
-/* { dg-additional-options "-m32" { target { i?86-*-* x86_64-*-* } } } */
 
 struct A
 {
Index: gcc.dg/tree-ssa/pr79327-2.c
===
--- gcc.dg/tree-ssa/pr79327-2.c (revision 246843)
+++ gcc.dg/t

Re: [PATCH, gfortran] Cleanup the submodule tests

2017-04-15 Thread Dominique d'Humières
I am currently testing the following patch that handle both modules and 
submodules. It is a little bit clumsy and may not handle all the possible 
syntax variants. Any comment welcomed!-) Testing in progress.

Dominique

--- ../_clean/gcc/testsuite/lib/fortran-modules.exp 2017-01-01 
17:38:58.0 +0100
+++ gcc/testsuite/lib/fortran-modules.exp   2017-04-16 01:16:25.0 
+0200
@@ -79,10 +79,11 @@ proc list-module-names { files } {
 
 proc list-module-names-1 { file } {
 set result {}
-set tmp [grep $file "^\[ \t\]*((#)?\[ 
\t\]*include|\[mM\]\[oO\]\[dD\]\[uU\]\[lL\]\[eE\](?!\[ 
\t\]+\[pP\]\[rR\]\[oO\]\[cC\]\[eE\]\[dD\]\[uU\]\[rR\]\[eE\]\[ \t\]+))\[ 
\t\]+.*" line]
+if {[file isdirectory $file]} {return}
+set tmp [igrep $file 
"^\\s*((#)?\\s*include|(sub)?module(?!\\s+(recursive\\s+)?(procedure|subroutine|function)\\s*))\\s*.*"
 line]
 if {![string match "" $tmp]} {
foreach i $tmp {
-   regexp "(\[0-9\]+)\[ \t\]+(?:(?:#)?\[ \t\]*include\[ 
\t\]+)\[\"\](\[^\"\]*)\[\"\]" $i dummy lineno include_file
+   regexp -nocase 
"(\[0-9\]+)\\s+(?:(?:#)?\\s*include\\s+)\[\"\'\](\[^\"\'\]*)\[\"\'\]" $i dummy 
lineno include_file
if {[info exists include_file]} {
set dir [file dirname $file]
set inc "$dir/$include_file"
@@ -99,7 +100,11 @@ proc list-module-names-1 { file } {
}
continue
}
-   regexp "(\[0-9\]+)\[ 
\t\]+(?:(\[mM\]\[oO\]\[dD\]\[uU\]\[lL\]\[eE\]\[ 
\t\]+(?!\[pP\]\[rR\]\[oO\]\[cC\]\[eE\]\[dD\]\[uU\]\[rR\]\[eE\]\[ \t\]+)))(\[^ 
\t;\]*)" $i i lineno keyword mod
+   regexp -nocase "(\[0-9\]+)\\s+(module|submodule)\\s*(\[^;\]*)" $i i 
lineno keyword mod
+   regsub "\\s*!.*" $mod "" mod
+   regsub ":\[^)\]*" $mod "" mod
+   regsub "\\(\\s*" $mod "" mod
+   regsub "\\s*\\)\\s*" $mod "@" mod
if {![info exists lineno]} {
continue
}
@@ -111,3 +116,54 @@ proc list-module-names-1 { file } {
 }
 return $result
 }
+
+# Looks for case insensitive occurrences of a string in a file.
+# return:list of lines that matched or NULL if none match.
+# args:  first arg is the filename,
+#second is the pattern,
+#third are any options.
+# Options: line  - puts line numbers of match in list
+#
+proc igrep { args } {
+
+set file [lindex $args 0]
+set pattern [lindex $args 1]
+
+verbose "Grepping $file for the pattern \"$pattern\"" 3
+
+set argc [llength $args]
+if { $argc > 2 } {
+for { set i 2 } { $i < $argc } { incr i } {
+append options [lindex $args $i]
+append options " "
+}
+} else {
+set options ""
+}
+
+set i 0
+set fd [open $file r]
+while { [gets $fd cur_line]>=0 } {
+incr i
+if {[regexp -nocase -- "$pattern" $cur_line match]} {
+if {![string match "" $options]} {
+foreach opt $options {
+switch $opt {
+"line" {
+lappend grep_out [concat $i $match]
+}
+}
+}
+} else {
+lappend grep_out $match
+}
+}
+}
+close $fd
+unset fd
+unset i
+if {![info exists grep_out]} {
+set grep_out ""
+}
+return $grep_out
+}

> Le 15 avr. 2017 à 18:50, Janus Weil  a écrit :
> 
> 2017-04-15 17:54 GMT+02:00 Dominique d'Humières :
 This is indeed doable, but before I’ld like to improve the module cleanup 
 with the following patch
>>> 
>>> Yes, looks very useful to me (makes the regexps much more compact &
>>> readable). In addition, couldn't one use \s for whitespace instead of
>>> \[ \t\]   ?
>> 
>> I have posted what I have in my working tree. I’ll test the use of \s 
>> instead of \[ \t\] . Is it really portable?
> 
> Not sure. But at least some of the other files in gcc/testsuite/lib
> seem to use \s as well (e.g. gcc-dg.exp).
> 
> 
>>> I assume your igrep is just a copy of dejagnu's grep with an additional 
>>> -nocase?
>> 
>> Yes!
> 
> Ok to commit  from my side, if you have tested that it works properly.
> 
> Cheers,
> Janus