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]

Re: [gfortran, testsuite] Don't give excess errors for multiple locion the same line


[adding gcc-patches@, which I missed in the previous mail]

Tobias Schlüter wrote:
>>Unfortunately this won't work, because the regexp which eats the fancy error
>>messages can only deal with a single locus, even if they're on the same line.
>> I found this out, by changing your patch to only print a single locus.
>>
>>I see two possible ways of fixing this:
>>1. fix the regexp
> 
> 
> Actually this wasn't hard at all.  Instead of skipping spaces and an
> arbitrary-digit number (which doesn't make sense anyway), with this patch we
> completely skip the locus line.  This doesn't yet fix the case where two loci
> on different lines are printed, because I don't know regexps too well, and
> instead of delaying this for a complete solution which will take me a while,
> this cures the immediate problem.

After some fighting with TCL and regular expressions, I created this patch
which passes the testsuite with no regressions.  I had to update a few
testcases, so that both lines for which an error locus is given is annotated.
 The regular expressions are quite ugly, and I'm open to comments on how to
make them more readable (how do I split strings across lines in TCL?).  Ok?

- Tobi

2005-02-20  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>

	* gfortran.dg/do_iterator: Split loop, markkup all lines for
	which an error locus is printed.
	* gfortran.dg/pr17708.f90: Markup all lines for which an error
	locus is printed.
	* gfortran.dg/select_4.f90: Likewise.
	* lib/gfortran-dg.exp (gfortran-dg-test): Handle gfortran error
	locuses in the various permutations.

Index: lib/gfortran-dg.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/gfortran-dg.exp,v
retrieving revision 1.3
diff -u -p -r1.3 gfortran-dg.exp
--- lib/gfortran-dg.exp 16 Jul 2004 00:32:26 -0000      1.3
+++ lib/gfortran-dg.exp 20 Feb 2005 19:17:16 -0000
@@ -1,4 +1,4 @@
-#   Copyright (C) 2004 Free Software Foundation, Inc.
+#   Copyright (C) 2004, 2005 Free Software Foundation, Inc.

 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,11 +25,44 @@ proc gfortran-dg-test { prog do_what ext
     set comp_output [lindex $result 0]
     set output_file [lindex $result 1]

-    # Put the error message on the same line as the line number
-    # FIXME: Add a colon after line number
-    # Remove the line of source code with the error and
-    # the number pointing to error
-    regsub -all "\n\n\[^\n\]*\n *\[0-9\]*\n" $comp_output ": " comp_output
+    # gfortran error messages look like this:
+    #      In file [name]:[line]
+    #
+    #        some code
+    #              1
+    #     Error: Some error at (1) and (2)
+    # or
+    #      In file [name]:[line]
+    #
+    #       some code
+    #              1
+    #      In file [name]:[line2]
+    #
+    #       some other code
+    #         2
+    #     Error: Some error at (1) and (2)
+    # or
+    #      In file [name]:[line]
+    #
+    #       some code and some more code
+    #              1       2
+    #     Error: Some error at (1) and (2)
+    #
+    # We collapse these to look like:
+    #  [name]:[line]: Error: Some error at (1) and (2)
+    # or
+    #  [name]:[line]: Error: Some error at (1) and (2)
+    #  [name]:[line2]: Error: Some error at (1) and (2)
+    # We proceed in two steps: first we deal with the form with two
+    # different locus lines, then with the form with only one locus line.
+#    puts "vorher"
+#    puts $comp_output
+    regsub -all " In file (\[^\n\]*)\n\n\[^\n\]*\n\[^\n\]*\n In file
(\[^\n\]*)\n\n\[^\n\]*\n\[^\n\]*\n(\[^\n\]*)\n" $comp_output "\\1: \\3\n\\2:
\\3\n"  comp_output
+#    puts "zwischen"
+#    puts $comp_output
+    regsub -all " In file (\[^\n\]*)\n\n\[^\n\]*\n\[^\n\]*\n(\[^\n\]*)\n"
$comp_output "\\1: \\2\n" comp_output
+#    puts "nde"
+#    puts $comp_output

     return [list $comp_output $output_file]
 }




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