public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug gcov-profile/41359] New: [fortran] 'else if' statement is discarded and incoherent line count
@ 2009-09-15 12:39 Edouard dot Canot at irisa dot fr
2009-09-15 13:07 ` [Bug gcov-profile/41359] " jv244 at cam dot ac dot uk
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Edouard dot Canot at irisa dot fr @ 2009-09-15 12:39 UTC (permalink / raw)
To: gcc-bugs
Considering the following fortran code:
=== begin code ===
program main
implicit none
integer :: a = 7
if( a == 0 ) then
print *, "a is null"
else if( a > 0 ) then
print *, "a is positif"
else
print *, "a is negatif"
end if
end program
=== end code ===
compiled with the "-fprofile-arcs -ftest-coverage" option flags,
linked with the same flags, with gfortran-4.3.4 or gfortran-4.4.1
After a single execution, the profile file is built as usual with:
$ gcov main
The resulting profile is then:
$ cat main.f90.gcov
-: 0:Source:main.f90
-: 0:Graph:main.gcno
-: 0:Data:main.gcda
-: 0:Runs:1
-: 0:Programs:1
1: 1:program main
-: 2:
-: 3: implicit none
-: 4:
-: 5: integer :: a = 7
-: 6:
3: 7: if( a == 0 ) then
#####: 8: print *, "a is null"
-: 9: else if( a > 0 ) then
1: 10: print *, "a is positif"
-: 11: else
#####: 12: print *, "a is negatif"
-: 13: end if
-: 14:
-: 15:end program
First remark: line 7 is marked '3' instead of '1'
Second remark: line 9 is discarded (marked '-') instead of '1'
When using the current snapshot of gfortran-4.5 (2009-09-15), the
result is slightly different:
$ cat main.f90.gcov
-: 0:Source:main.f90
-: 0:Graph:main.gcno
-: 0:Data:main.gcda
-: 0:Runs:1
-: 0:Programs:1
1: 1:program main
-: 2:
-: 3: implicit none
-: 4:
-: 5: integer :: a = 7
-: 6:
2: 7: if( a == 0 ) then
#####: 8: print *, "a is null"
-: 9: else if( a > 0 ) then
1: 10: print *, "a is positif"
-: 11: else
#####: 12: print *, "a is negatif"
-: 13: end if
-: 14:
2: 15:end program
Note that line 7 is counted twice, as well as the last line !
--
Summary: [fortran] 'else if' statement is discarded and
incoherent line count
Product: gcc
Version: 4.3.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Edouard dot Canot at irisa dot fr
GCC build triplet: i686-linux-gnu
GCC host triplet: i686-linux-gnu
GCC target triplet: i686-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41359
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug gcov-profile/41359] [fortran] 'else if' statement is discarded and incoherent line count
2009-09-15 12:39 [Bug gcov-profile/41359] New: [fortran] 'else if' statement is discarded and incoherent line count Edouard dot Canot at irisa dot fr
@ 2009-09-15 13:07 ` jv244 at cam dot ac dot uk
2010-04-10 19:04 ` [Bug fortran/41359] Wrong line numbers for debugging/profiling jv244 at cam dot ac dot uk
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jv244 at cam dot ac dot uk @ 2009-09-15 13:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from jv244 at cam dot ac dot uk 2009-09-15 13:07 -------
As you can see with
gfortran -fdump-tree-original-lineno test.f90
which leads to garbage line numbers in
gfortran -fdump-tree-gimple-lineno test.f90
I believe there is some similarity to PR40823
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40823
I guess that this case could be a regression with respect to g77, but can't
test it.
--
jv244 at cam dot ac dot uk changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2009-09-15 13:07:14
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41359
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/41359] Wrong line numbers for debugging/profiling
2009-09-15 12:39 [Bug gcov-profile/41359] New: [fortran] 'else if' statement is discarded and incoherent line count Edouard dot Canot at irisa dot fr
2009-09-15 13:07 ` [Bug gcov-profile/41359] " jv244 at cam dot ac dot uk
@ 2010-04-10 19:04 ` jv244 at cam dot ac dot uk
2010-04-10 21:27 ` mikael at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jv244 at cam dot ac dot uk @ 2010-04-10 19:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jv244 at cam dot ac dot uk 2010-04-10 19:04 -------
still present in 4.6. The issue seems to be missing location info for the
nested if [if (a>0) ], the missing info in the original dump appears as a
incorrect line:7 in the gimple. It is specific to the 'else if' form, on a
single line.
--
jv244 at cam dot ac dot uk changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail|4.3.4 4.4.1 4.5.0 |4.3.4 4.4.1 4.5.0 4.6.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41359
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/41359] Wrong line numbers for debugging/profiling
2009-09-15 12:39 [Bug gcov-profile/41359] New: [fortran] 'else if' statement is discarded and incoherent line count Edouard dot Canot at irisa dot fr
2009-09-15 13:07 ` [Bug gcov-profile/41359] " jv244 at cam dot ac dot uk
2010-04-10 19:04 ` [Bug fortran/41359] Wrong line numbers for debugging/profiling jv244 at cam dot ac dot uk
@ 2010-04-10 21:27 ` mikael at gcc dot gnu dot org
2010-04-11 18:03 ` jv244 at cam dot ac dot uk
2010-07-28 20:01 ` mikael at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: mikael at gcc dot gnu dot org @ 2010-04-10 21:27 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from mikael at gcc dot gnu dot org 2010-04-10 21:27 -------
With this :
diff --git a/trans-expr.c b/trans-expr.c
index 7e95ce1..a6f8616 100644
--- a/trans-expr.c
+++ b/trans-expr.c
@@ -1382,6 +1382,8 @@ gfc_conv_expr_op (gfc_se * se, gfc_expr * expr)
else
se->expr = fold_build2 (code, type, lse.expr, rse.expr);
+ SET_EXPR_LOCATION (se->expr, expr->where.lb->location);
+
/* Add the post blocks. */
gfc_add_block_to_block (&se->post, &rse.post);
gfc_add_block_to_block (&se->post, &lse.post);
diff --git a/trans-stmt.c b/trans-stmt.c
index 0b215f2..4b8ae69 100644
--- a/trans-stmt.c
+++ b/trans-stmt.c
@@ -718,6 +718,7 @@ gfc_trans_if_1 (gfc_code * code)
/* Build the condition expression and add it to the condition block. */
stmt = fold_build3 (COND_EXPR, void_type_node, if_se.expr, stmt, elsestmt);
+ SET_EXPR_LOCATION (stmt, code->loc.lb->location);
gfc_add_expr_to_block (&if_se.pre, stmt);
I get :
-: 0:Source:pr41359.f90
-: 0:Graph:pr41359.gcno
-: 0:Data:pr41359.gcda
-: 0:Runs:1
-: 0:Programs:1
1: 1:program main
-: 2:
-: 3: implicit none
-: 4:
-: 5: integer :: a = 7
-: 6:
1: 7: if( a == 0 ) then
#####: 8: print *, "a is null"
1: 9: else if( a > 0 ) then
1: 10: print *, "a is positif"
-: 11: else
#####: 12: print *, "a is negatif"
-: 13: end if
-: 14:
2: 15:end program
-: 16:
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41359
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/41359] Wrong line numbers for debugging/profiling
2009-09-15 12:39 [Bug gcov-profile/41359] New: [fortran] 'else if' statement is discarded and incoherent line count Edouard dot Canot at irisa dot fr
` (2 preceding siblings ...)
2010-04-10 21:27 ` mikael at gcc dot gnu dot org
@ 2010-04-11 18:03 ` jv244 at cam dot ac dot uk
2010-07-28 20:01 ` mikael at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: jv244 at cam dot ac dot uk @ 2010-04-11 18:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jv244 at cam dot ac dot uk 2010-04-11 18:02 -------
looks like we have a patch...
--
jv244 at cam dot ac dot uk changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41359
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/41359] Wrong line numbers for debugging/profiling
2009-09-15 12:39 [Bug gcov-profile/41359] New: [fortran] 'else if' statement is discarded and incoherent line count Edouard dot Canot at irisa dot fr
` (3 preceding siblings ...)
2010-04-11 18:03 ` jv244 at cam dot ac dot uk
@ 2010-07-28 20:01 ` mikael at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: mikael at gcc dot gnu dot org @ 2010-07-28 20:01 UTC (permalink / raw)
To: gcc-bugs
--
mikael at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |mikael at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2009-09-15 13:07:14 |2010-07-28 20:01:09
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41359
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-07-28 20:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-15 12:39 [Bug gcov-profile/41359] New: [fortran] 'else if' statement is discarded and incoherent line count Edouard dot Canot at irisa dot fr
2009-09-15 13:07 ` [Bug gcov-profile/41359] " jv244 at cam dot ac dot uk
2010-04-10 19:04 ` [Bug fortran/41359] Wrong line numbers for debugging/profiling jv244 at cam dot ac dot uk
2010-04-10 21:27 ` mikael at gcc dot gnu dot org
2010-04-11 18:03 ` jv244 at cam dot ac dot uk
2010-07-28 20:01 ` mikael at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).