* [PATCH] lower gimple: Sustain line number info for returns if possible
@ 2011-02-07 14:40 Andreas Krebbel
2011-02-07 15:21 ` Richard Guenther
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Andreas Krebbel @ 2011-02-07 14:40 UTC (permalink / raw)
To: gcc-patches
Hi,
I see several guality tests failing on s390 because the line number
info of the return statement of a function is lost. The information
is lost when lower gimple tries to merge return statements by adding
gotos. The line number info is removed in lower_function_body since
the return might now be used for implementing several returns at
different code locations. However the removal isn't necessary if a
merge did not actually occur.
The attached patch moves the removal of the line info from
lower_function_body to lower_gimple_return and only does the removal
if the return statement is actually re-used.
This fixes 91 testsuite fails on s390x. However there are a few new
fails where the line numbers of warnings have changed due to more
return statements having line number information now:
> FAIL: gcc.dg/noreturn-1.c detect return from noreturn (test for warnings, line 38)
> FAIL: gcc.dg/noreturn-1.c (test for excess errors)
> FAIL: gcc.dg/pr39666-2.c (test for warnings, line 8)
> FAIL: gcc.dg/pr39666-2.c (test for excess errors)
> FAIL: gcc.dg/uninit-pr19430.c (test for warnings, line 21)
> FAIL: gcc.dg/uninit-pr19430.c (test for excess errors)
> FAIL: c-c++-common/pr20000.c -Wc++-compat (test for warnings, line 13)
> FAIL: c-c++-common/pr20000.c -Wc++-compat (test for warnings, line 28)
> FAIL: c-c++-common/pr20000.c -Wc++-compat (test for excess errors)
I'll post patches moving the expected warnings in the testcases accordingly.
Bootstrapped on s390x.
Ok for mainline?
Bye,
-Andreas-
2011-02-07 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* gimple-low.c (lower_function_body): Don't remove the location of
the return statement here.
(lower_gimple_return): Do it here instead but only if the return
statement is actually used twice.
Index: gcc/gimple-low.c
===================================================================
*** gcc/gimple-low.c.orig
--- gcc/gimple-low.c
*************** lower_function_body (void)
*** 148,158 ****
x = gimple_build_label (t.label);
gsi_insert_after (&i, x, GSI_CONTINUE_LINKING);
-
- /* Remove the line number from the representative return statement.
- It now fills in for many such returns. Failure to remove this
- will result in incorrect results for coverage analysis. */
- gimple_set_location (t.stmt, UNKNOWN_LOCATION);
gsi_insert_after (&i, t.stmt, GSI_CONTINUE_LINKING);
}
--- 148,153 ----
*************** lower_gimple_return (gimple_stmt_iterato
*** 746,752 ****
tmp_rs = *VEC_index (return_statements_t, data->return_statements, i);
if (gimple_return_retval (stmt) == gimple_return_retval (tmp_rs.stmt))
! goto found;
}
/* Not found. Create a new label and record the return statement. */
--- 741,754 ----
tmp_rs = *VEC_index (return_statements_t, data->return_statements, i);
if (gimple_return_retval (stmt) == gimple_return_retval (tmp_rs.stmt))
! {
! /* Remove the line number from the representative return statement.
! It now fills in for many such returns. Failure to remove this
! will result in incorrect results for coverage analysis. */
! gimple_set_location (tmp_rs.stmt, UNKNOWN_LOCATION);
!
! goto found;
! }
}
/* Not found. Create a new label and record the return statement. */
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] lower gimple: Sustain line number info for returns if possible
2011-02-07 14:40 [PATCH] lower gimple: Sustain line number info for returns if possible Andreas Krebbel
@ 2011-02-07 15:21 ` Richard Guenther
2011-02-07 18:15 ` Eric Botcazou
2011-02-08 14:57 ` H.J. Lu
2011-02-08 16:33 ` Andreas Krebbel
2 siblings, 1 reply; 9+ messages in thread
From: Richard Guenther @ 2011-02-07 15:21 UTC (permalink / raw)
To: Andreas Krebbel; +Cc: gcc-patches
On Mon, Feb 7, 2011 at 3:40 PM, Andreas Krebbel
<krebbel@linux.vnet.ibm.com> wrote:
> Hi,
>
> I see several guality tests failing on s390 because the line number
> info of the return statement of a function is lost. The information
> is lost when lower gimple tries to merge return statements by adding
> gotos. The line number info is removed in lower_function_body since
> the return might now be used for implementing several returns at
> different code locations. However the removal isn't necessary if a
> merge did not actually occur.
>
> The attached patch moves the removal of the line info from
> lower_function_body to lower_gimple_return and only does the removal
> if the return statement is actually re-used.
>
> This fixes 91 testsuite fails on s390x. However there are a few new
> fails where the line numbers of warnings have changed due to more
> return statements having line number information now:
>
>> FAIL: gcc.dg/noreturn-1.c detect return from noreturn (test for warnings, line 38)
>> FAIL: gcc.dg/noreturn-1.c (test for excess errors)
>> FAIL: gcc.dg/pr39666-2.c (test for warnings, line 8)
>> FAIL: gcc.dg/pr39666-2.c (test for excess errors)
>> FAIL: gcc.dg/uninit-pr19430.c (test for warnings, line 21)
>> FAIL: gcc.dg/uninit-pr19430.c (test for excess errors)
>> FAIL: c-c++-common/pr20000.c -Wc++-compat (test for warnings, line 13)
>> FAIL: c-c++-common/pr20000.c -Wc++-compat (test for warnings, line 28)
>> FAIL: c-c++-common/pr20000.c -Wc++-compat (test for excess errors)
>
> I'll post patches moving the expected warnings in the testcases accordingly.
>
> Bootstrapped on s390x.
>
> Ok for mainline?
Hum, most of the code looks overly complicated given that we
gimplify returns to
<retval> = val;
return <retval>;
which means that the duplicate search is pointless to some extent.
We only keep one return without value and one return.
That said - we do have locations on the gotos which should get
transitioned to goto locations on edges which in the end should
flow to the single return and be merged if equal. So it sounds
like this kind of thing does not happen?
Richard.
> Bye,
>
> -Andreas-
>
>
> 2011-02-07 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
>
> * gimple-low.c (lower_function_body): Don't remove the location of
> the return statement here.
> (lower_gimple_return): Do it here instead but only if the return
> statement is actually used twice.
>
>
> Index: gcc/gimple-low.c
> ===================================================================
> *** gcc/gimple-low.c.orig
> --- gcc/gimple-low.c
> *************** lower_function_body (void)
> *** 148,158 ****
>
> x = gimple_build_label (t.label);
> gsi_insert_after (&i, x, GSI_CONTINUE_LINKING);
> -
> - /* Remove the line number from the representative return statement.
> - It now fills in for many such returns. Failure to remove this
> - will result in incorrect results for coverage analysis. */
> - gimple_set_location (t.stmt, UNKNOWN_LOCATION);
> gsi_insert_after (&i, t.stmt, GSI_CONTINUE_LINKING);
> }
>
> --- 148,153 ----
> *************** lower_gimple_return (gimple_stmt_iterato
> *** 746,752 ****
> tmp_rs = *VEC_index (return_statements_t, data->return_statements, i);
>
> if (gimple_return_retval (stmt) == gimple_return_retval (tmp_rs.stmt))
> ! goto found;
> }
>
> /* Not found. Create a new label and record the return statement. */
> --- 741,754 ----
> tmp_rs = *VEC_index (return_statements_t, data->return_statements, i);
>
> if (gimple_return_retval (stmt) == gimple_return_retval (tmp_rs.stmt))
> ! {
> ! /* Remove the line number from the representative return statement.
> ! It now fills in for many such returns. Failure to remove this
> ! will result in incorrect results for coverage analysis. */
> ! gimple_set_location (tmp_rs.stmt, UNKNOWN_LOCATION);
> !
> ! goto found;
> ! }
> }
>
> /* Not found. Create a new label and record the return statement. */
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] lower gimple: Sustain line number info for returns if possible
2011-02-07 15:21 ` Richard Guenther
@ 2011-02-07 18:15 ` Eric Botcazou
2011-02-08 10:43 ` Richard Guenther
0 siblings, 1 reply; 9+ messages in thread
From: Eric Botcazou @ 2011-02-07 18:15 UTC (permalink / raw)
To: Richard Guenther; +Cc: gcc-patches, Andreas Krebbel
> That said - we do have locations on the gotos which should get
> transitioned to goto locations on edges which in the end should
> flow to the single return and be merged if equal. So it sounds
FWIW we have had this patch in our 4.5 tree for some time now, it's necessary
to have correct coverage result at -O. When you have only one goto for a
return, RTL can easily optimize away/forward propagate the instructions
generated for the user return (just before the goto) and so you lose the
location of the user return if the goto edge doesn't keep it. When you have
several gotos for a return, RTL cannot easily optimize the instructions and
the location of the user returns are preserved even if the goto edges don't
have it.
--
Eric Botcazou
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] lower gimple: Sustain line number info for returns if possible
2011-02-07 18:15 ` Eric Botcazou
@ 2011-02-08 10:43 ` Richard Guenther
0 siblings, 0 replies; 9+ messages in thread
From: Richard Guenther @ 2011-02-08 10:43 UTC (permalink / raw)
To: Eric Botcazou; +Cc: gcc-patches, Andreas Krebbel
On Mon, Feb 7, 2011 at 7:12 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> That said - we do have locations on the gotos which should get
>> transitioned to goto locations on edges which in the end should
>> flow to the single return and be merged if equal. So it sounds
>
> FWIW we have had this patch in our 4.5 tree for some time now, it's necessary
> to have correct coverage result at -O. When you have only one goto for a
> return, RTL can easily optimize away/forward propagate the instructions
> generated for the user return (just before the goto) and so you lose the
> location of the user return if the goto edge doesn't keep it. When you have
> several gotos for a return, RTL cannot easily optimize the instructions and
> the location of the user returns are preserved even if the goto edges don't
> have it.
I see. The lowering code needs some TLC after tuples (the IL is more
canonical now), but I guess after some discussion IRC the patch is ok
as-is. We can try simplifying the lowering code for 4.7.
Thanks,
Richard.
> --
> Eric Botcazou
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] lower gimple: Sustain line number info for returns if possible
2011-02-07 14:40 [PATCH] lower gimple: Sustain line number info for returns if possible Andreas Krebbel
2011-02-07 15:21 ` Richard Guenther
@ 2011-02-08 14:57 ` H.J. Lu
2011-02-08 16:28 ` Andreas Krebbel
2011-02-08 16:33 ` Andreas Krebbel
2 siblings, 1 reply; 9+ messages in thread
From: H.J. Lu @ 2011-02-08 14:57 UTC (permalink / raw)
To: Andreas Krebbel; +Cc: gcc-patches
On Mon, Feb 7, 2011 at 6:40 AM, Andreas Krebbel
<krebbel@linux.vnet.ibm.com> wrote:
> Hi,
>
> I see several guality tests failing on s390 because the line number
> info of the return statement of a function is lost. The information
> is lost when lower gimple tries to merge return statements by adding
> gotos. The line number info is removed in lower_function_body since
> the return might now be used for implementing several returns at
> different code locations. However the removal isn't necessary if a
> merge did not actually occur.
>
> The attached patch moves the removal of the line info from
> lower_function_body to lower_gimple_return and only does the removal
> if the return statement is actually re-used.
>
> This fixes 91 testsuite fails on s390x. However there are a few new
> fails where the line numbers of warnings have changed due to more
> return statements having line number information now:
>
>> FAIL: gcc.dg/noreturn-1.c detect return from noreturn (test for warnings, line 38)
>> FAIL: gcc.dg/noreturn-1.c (test for excess errors)
>> FAIL: gcc.dg/pr39666-2.c (test for warnings, line 8)
>> FAIL: gcc.dg/pr39666-2.c (test for excess errors)
>> FAIL: gcc.dg/uninit-pr19430.c (test for warnings, line 21)
>> FAIL: gcc.dg/uninit-pr19430.c (test for excess errors)
>> FAIL: c-c++-common/pr20000.c -Wc++-compat (test for warnings, line 13)
>> FAIL: c-c++-common/pr20000.c -Wc++-compat (test for warnings, line 28)
>> FAIL: c-c++-common/pr20000.c -Wc++-compat (test for excess errors)
>
> I'll post patches moving the expected warnings in the testcases accordingly.
>
> Bootstrapped on s390x.
>
> Ok for mainline?
>
> Bye,
>
> -Andreas-
>
>
> 2011-02-07 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
>
> * gimple-low.c (lower_function_body): Don't remove the location of
> the return statement here.
> (lower_gimple_return): Do it here instead but only if the return
> statement is actually used twice.
>
>
I opened:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47646
--
H.J.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] lower gimple: Sustain line number info for returns if possible
2011-02-08 14:57 ` H.J. Lu
@ 2011-02-08 16:28 ` Andreas Krebbel
2011-02-08 16:43 ` Richard Guenther
2011-02-09 19:23 ` Eric Botcazou
0 siblings, 2 replies; 9+ messages in thread
From: Andreas Krebbel @ 2011-02-08 16:28 UTC (permalink / raw)
To: H.J. Lu; +Cc: gcc-patches, rguenther
> I opened:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47646
Hi,
this should fix the testsuite regressions.
There are two changes caused by having line number info at some return
statements now:
1. "may be uninitialized" warnings will be issued either for the using
statement or for the var decl. Now we run into the first (preferred)
case if the return statement is the only user of the variable.
2. "'noreturn' function does return" will now be issued for the return
if possible otherwise the code still falls back to the function end
location.
I've adjusted the testcases accordingly.
Ok for mainline?
Bye,
-Andreas-
2011-02-08 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
PR middle-end/47646
* gcc.dg/pr39666-2.c (foo2): If the location of the statement
using the variable is known the warning is emitted there.
* gcc.dg/uninit-pr19430.c (foo): Likewise.
* g++.dg/warn/Wuninitialized-5.C (foo): Likewise.
* c-c++-common/pr20000.c (g): Both warnings occur at the return
statement.
(vg): Likewise.
* gcc.dg/noreturn-1.c (foo5): Likewise.
* objc.dg/attributes/method-noreturn-1.m (method1): Likewise.
(method2): Likewise.
* gfortran.dg/pr25923.f90 (baz): The warning will now be issued for
the return statement using the uninitialized variable.
* gfortran.dg/pr39666-2.f90 (f): Likewise.
Index: gcc/testsuite/gcc.dg/pr39666-2.c
===================================================================
*** gcc/testsuite/gcc.dg/pr39666-2.c.orig
--- gcc/testsuite/gcc.dg/pr39666-2.c
***************
*** 5,11 ****
int
foo (int i)
{
! int j; /* { dg-warning "may be used uninitialized" } */
switch (i)
{
case -__INT_MAX__ - 1 ... -1:
--- 5,11 ----
int
foo (int i)
{
! int j;
switch (i)
{
case -__INT_MAX__ - 1 ... -1:
*************** foo (int i)
*** 18,22 ****
j = 4;
break;
}
! return j;
}
--- 18,22 ----
j = 4;
break;
}
! return j; /* { dg-warning "may be used uninitialized" } */
}
Index: gcc/testsuite/gcc.dg/uninit-pr19430.c
===================================================================
*** gcc/testsuite/gcc.dg/uninit-pr19430.c.orig
--- gcc/testsuite/gcc.dg/uninit-pr19430.c
*************** foo (int i)
*** 18,25 ****
int foo2( void ) {
! int rc; /* { dg-warning "'rc' is used uninitialized in this function" } */
! return rc;
*&rc = 0;
}
--- 18,25 ----
int foo2( void ) {
! int rc;
! return rc; /* { dg-warning "'rc' is used uninitialized in this function" } */
*&rc = 0;
}
Index: gcc/testsuite/c-c++-common/pr20000.c
===================================================================
*** gcc/testsuite/c-c++-common/pr20000.c.orig
--- gcc/testsuite/c-c++-common/pr20000.c
*************** void h(void) __attribute__((noreturn));
*** 10,16 ****
int g(void) {
return 1; /* { dg-warning "function declared 'noreturn' has a 'return' statement" } */
! } /* { dg-warning "'noreturn' function does return" } */
int g2(void) {
h();
--- 10,16 ----
int g(void) {
return 1; /* { dg-warning "function declared 'noreturn' has a 'return' statement" } */
! } /* { dg-warning "'noreturn' function does return" "" { target *-*-* } 12 } */
int g2(void) {
h();
*************** int vg2(void); /* { dg-bogus ".noreturn.
*** 25,31 ****
int vg(void) {
return 1; /* { dg-warning "function declared 'noreturn' has a 'return' statement" "" { target c } 27 } */
! } /* { dg-warning "'noreturn' function does return" "" { target c } 28 } */
int vg2(void) {
h();
--- 25,31 ----
int vg(void) {
return 1; /* { dg-warning "function declared 'noreturn' has a 'return' statement" "" { target c } 27 } */
! } /* { dg-warning "'noreturn' function does return" "" { target c } 27 } */
int vg2(void) {
h();
Index: gcc/testsuite/gcc.dg/noreturn-1.c
===================================================================
*** gcc/testsuite/gcc.dg/noreturn-1.c.orig
--- gcc/testsuite/gcc.dg/noreturn-1.c
*************** void
*** 35,41 ****
foo5(void)
{
return; /* { dg-warning "'noreturn' has a 'return' statement" "detect invalid return" } */
! } /* { dg-warning "function does return" "detect return from noreturn" } */
extern void foo6(void);
void
--- 35,41 ----
foo5(void)
{
return; /* { dg-warning "'noreturn' has a 'return' statement" "detect invalid return" } */
! } /* { dg-warning "function does return" "detect return from noreturn" { target c } 37 } */
extern void foo6(void);
void
Index: gcc/testsuite/g++.dg/warn/Wuninitialized-5.C
===================================================================
*** gcc/testsuite/g++.dg/warn/Wuninitialized-5.C.orig
--- gcc/testsuite/g++.dg/warn/Wuninitialized-5.C
***************
*** 5,11 ****
int
foo (int i)
{
! int j; // { dg-warning "may be used uninitialized" }
switch (i)
{
case -__INT_MAX__ - 1 ... -1:
--- 5,11 ----
int
foo (int i)
{
! int j;
switch (i)
{
case -__INT_MAX__ - 1 ... -1:
*************** foo (int i)
*** 18,22 ****
j = 4;
break;
}
! return j;
}
--- 18,22 ----
j = 4;
break;
}
! return j; // { dg-warning "may be used uninitialized" }
}
Index: gcc/testsuite/gfortran.dg/pr25923.f90
===================================================================
*** gcc/testsuite/gfortran.dg/pr25923.f90.orig
--- gcc/testsuite/gfortran.dg/pr25923.f90
*************** implicit none
*** 10,16 ****
contains
! function baz(arg) result(res) ! { dg-warning "res.yr' may be" "PR45505" { xfail ilp32 } }
type(bar), intent(in) :: arg
type(bar) :: res
logical, external:: some_func
--- 10,16 ----
contains
! function baz(arg) result(res) ! { dg-bogus "res.yr' may be" "PR45505" { xfail ilp32 } }
type(bar), intent(in) :: arg
type(bar) :: res
logical, external:: some_func
*************** contains
*** 19,25 ****
else
res = arg
end if
! end function baz ! { dg-bogus "res.yr' may be" "PR45505" { xfail ilp32 } }
end module foo
--- 19,25 ----
else
res = arg
end if
! end function baz ! { dg-warning "res.yr' may be" "PR45505" { xfail ilp32 } }
end module foo
Index: gcc/testsuite/gfortran.dg/pr39666-2.f90
===================================================================
*** gcc/testsuite/gfortran.dg/pr39666-2.f90.orig
--- gcc/testsuite/gfortran.dg/pr39666-2.f90
***************
*** 2,8 ****
! { dg-do compile }
! { dg-options "-O2 -Wuninitialized" }
! FUNCTION f(n) ! { dg-warning "may be used uninitialized" }
INTEGER, INTENT(in) :: n
REAL :: f
--- 2,8 ----
! { dg-do compile }
! { dg-options "-O2 -Wuninitialized" }
! FUNCTION f(n)
INTEGER, INTENT(in) :: n
REAL :: f
*************** FUNCTION f(n) ! { dg-warning "may be use
*** 11,14 ****
CASE (0); f = 0.0
CASE (2:); f = 1.0
END SELECT
! END FUNCTION
--- 11,14 ----
CASE (0); f = 0.0
CASE (2:); f = 1.0
END SELECT
! END FUNCTION ! { dg-warning "may be used uninitialized" }
Index: gcc/testsuite/objc.dg/attributes/method-noreturn-1.m
===================================================================
*** gcc/testsuite/objc.dg/attributes/method-noreturn-1.m.orig
--- gcc/testsuite/objc.dg/attributes/method-noreturn-1.m
***************
*** 18,28 ****
+ (id) method1
{
return self; /* { dg-warning "function declared .noreturn. has a .return. statement" } */
! } /* { dg-warning ".noreturn. function does return" } */
- (id) method2
{
return self; /* { dg-warning "function declared .noreturn. has a .return. statement" } */
! } /* { dg-warning ".noreturn. function does return" } */
+ (id) method3
{
abort ();
--- 18,28 ----
+ (id) method1
{
return self; /* { dg-warning "function declared .noreturn. has a .return. statement" } */
! } /* { dg-warning ".noreturn. function does return" "" { target *-*-* } 20 } */
- (id) method2
{
return self; /* { dg-warning "function declared .noreturn. has a .return. statement" } */
! } /* { dg-warning ".noreturn. function does return" "" { target *-*-* } 24 } */
+ (id) method3
{
abort ();
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] lower gimple: Sustain line number info for returns if possible
2011-02-07 14:40 [PATCH] lower gimple: Sustain line number info for returns if possible Andreas Krebbel
2011-02-07 15:21 ` Richard Guenther
2011-02-08 14:57 ` H.J. Lu
@ 2011-02-08 16:33 ` Andreas Krebbel
2 siblings, 0 replies; 9+ messages in thread
From: Andreas Krebbel @ 2011-02-08 16:33 UTC (permalink / raw)
Cc: gcc-patches
> This fixes 91 testsuite fails on s390x.
This number seems to be totally wrong. I had a broken GDB installed. It probably only
fixes the testcase I actually debugged :(
Bye,
-Andreas-
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] lower gimple: Sustain line number info for returns if possible
2011-02-08 16:28 ` Andreas Krebbel
@ 2011-02-08 16:43 ` Richard Guenther
2011-02-09 19:23 ` Eric Botcazou
1 sibling, 0 replies; 9+ messages in thread
From: Richard Guenther @ 2011-02-08 16:43 UTC (permalink / raw)
To: Andreas Krebbel; +Cc: H.J. Lu, gcc-patches
On Tue, 8 Feb 2011, Andreas Krebbel wrote:
> > I opened:
> >
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47646
>
> Hi,
>
> this should fix the testsuite regressions.
>
> There are two changes caused by having line number info at some return
> statements now:
>
> 1. "may be uninitialized" warnings will be issued either for the using
> statement or for the var decl. Now we run into the first (preferred)
> case if the return statement is the only user of the variable.
>
> 2. "'noreturn' function does return" will now be issued for the return
> if possible otherwise the code still falls back to the function end
> location.
>
> I've adjusted the testcases accordingly.
>
> Ok for mainline?
Ok.
Thanks,
Richard.
> Bye,
>
> -Andreas-
>
>
> 2011-02-08 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
>
> PR middle-end/47646
> * gcc.dg/pr39666-2.c (foo2): If the location of the statement
> using the variable is known the warning is emitted there.
> * gcc.dg/uninit-pr19430.c (foo): Likewise.
> * g++.dg/warn/Wuninitialized-5.C (foo): Likewise.
>
> * c-c++-common/pr20000.c (g): Both warnings occur at the return
> statement.
> (vg): Likewise.
> * gcc.dg/noreturn-1.c (foo5): Likewise.
> * objc.dg/attributes/method-noreturn-1.m (method1): Likewise.
> (method2): Likewise.
>
> * gfortran.dg/pr25923.f90 (baz): The warning will now be issued for
> the return statement using the uninitialized variable.
> * gfortran.dg/pr39666-2.f90 (f): Likewise.
>
>
> Index: gcc/testsuite/gcc.dg/pr39666-2.c
> ===================================================================
> *** gcc/testsuite/gcc.dg/pr39666-2.c.orig
> --- gcc/testsuite/gcc.dg/pr39666-2.c
> ***************
> *** 5,11 ****
> int
> foo (int i)
> {
> ! int j; /* { dg-warning "may be used uninitialized" } */
> switch (i)
> {
> case -__INT_MAX__ - 1 ... -1:
> --- 5,11 ----
> int
> foo (int i)
> {
> ! int j;
> switch (i)
> {
> case -__INT_MAX__ - 1 ... -1:
> *************** foo (int i)
> *** 18,22 ****
> j = 4;
> break;
> }
> ! return j;
> }
> --- 18,22 ----
> j = 4;
> break;
> }
> ! return j; /* { dg-warning "may be used uninitialized" } */
> }
> Index: gcc/testsuite/gcc.dg/uninit-pr19430.c
> ===================================================================
> *** gcc/testsuite/gcc.dg/uninit-pr19430.c.orig
> --- gcc/testsuite/gcc.dg/uninit-pr19430.c
> *************** foo (int i)
> *** 18,25 ****
>
>
> int foo2( void ) {
> ! int rc; /* { dg-warning "'rc' is used uninitialized in this function" } */
> ! return rc;
> *&rc = 0;
> }
>
> --- 18,25 ----
>
>
> int foo2( void ) {
> ! int rc;
> ! return rc; /* { dg-warning "'rc' is used uninitialized in this function" } */
> *&rc = 0;
> }
>
> Index: gcc/testsuite/c-c++-common/pr20000.c
> ===================================================================
> *** gcc/testsuite/c-c++-common/pr20000.c.orig
> --- gcc/testsuite/c-c++-common/pr20000.c
> *************** void h(void) __attribute__((noreturn));
> *** 10,16 ****
>
> int g(void) {
> return 1; /* { dg-warning "function declared 'noreturn' has a 'return' statement" } */
> ! } /* { dg-warning "'noreturn' function does return" } */
>
> int g2(void) {
> h();
> --- 10,16 ----
>
> int g(void) {
> return 1; /* { dg-warning "function declared 'noreturn' has a 'return' statement" } */
> ! } /* { dg-warning "'noreturn' function does return" "" { target *-*-* } 12 } */
>
> int g2(void) {
> h();
> *************** int vg2(void); /* { dg-bogus ".noreturn.
> *** 25,31 ****
>
> int vg(void) {
> return 1; /* { dg-warning "function declared 'noreturn' has a 'return' statement" "" { target c } 27 } */
> ! } /* { dg-warning "'noreturn' function does return" "" { target c } 28 } */
>
> int vg2(void) {
> h();
> --- 25,31 ----
>
> int vg(void) {
> return 1; /* { dg-warning "function declared 'noreturn' has a 'return' statement" "" { target c } 27 } */
> ! } /* { dg-warning "'noreturn' function does return" "" { target c } 27 } */
>
> int vg2(void) {
> h();
> Index: gcc/testsuite/gcc.dg/noreturn-1.c
> ===================================================================
> *** gcc/testsuite/gcc.dg/noreturn-1.c.orig
> --- gcc/testsuite/gcc.dg/noreturn-1.c
> *************** void
> *** 35,41 ****
> foo5(void)
> {
> return; /* { dg-warning "'noreturn' has a 'return' statement" "detect invalid return" } */
> ! } /* { dg-warning "function does return" "detect return from noreturn" } */
>
> extern void foo6(void);
> void
> --- 35,41 ----
> foo5(void)
> {
> return; /* { dg-warning "'noreturn' has a 'return' statement" "detect invalid return" } */
> ! } /* { dg-warning "function does return" "detect return from noreturn" { target c } 37 } */
>
> extern void foo6(void);
> void
> Index: gcc/testsuite/g++.dg/warn/Wuninitialized-5.C
> ===================================================================
> *** gcc/testsuite/g++.dg/warn/Wuninitialized-5.C.orig
> --- gcc/testsuite/g++.dg/warn/Wuninitialized-5.C
> ***************
> *** 5,11 ****
> int
> foo (int i)
> {
> ! int j; // { dg-warning "may be used uninitialized" }
> switch (i)
> {
> case -__INT_MAX__ - 1 ... -1:
> --- 5,11 ----
> int
> foo (int i)
> {
> ! int j;
> switch (i)
> {
> case -__INT_MAX__ - 1 ... -1:
> *************** foo (int i)
> *** 18,22 ****
> j = 4;
> break;
> }
> ! return j;
> }
> --- 18,22 ----
> j = 4;
> break;
> }
> ! return j; // { dg-warning "may be used uninitialized" }
> }
> Index: gcc/testsuite/gfortran.dg/pr25923.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/pr25923.f90.orig
> --- gcc/testsuite/gfortran.dg/pr25923.f90
> *************** implicit none
> *** 10,16 ****
>
> contains
>
> ! function baz(arg) result(res) ! { dg-warning "res.yr' may be" "PR45505" { xfail ilp32 } }
> type(bar), intent(in) :: arg
> type(bar) :: res
> logical, external:: some_func
> --- 10,16 ----
>
> contains
>
> ! function baz(arg) result(res) ! { dg-bogus "res.yr' may be" "PR45505" { xfail ilp32 } }
> type(bar), intent(in) :: arg
> type(bar) :: res
> logical, external:: some_func
> *************** contains
> *** 19,25 ****
> else
> res = arg
> end if
> ! end function baz ! { dg-bogus "res.yr' may be" "PR45505" { xfail ilp32 } }
>
> end module foo
>
> --- 19,25 ----
> else
> res = arg
> end if
> ! end function baz ! { dg-warning "res.yr' may be" "PR45505" { xfail ilp32 } }
>
> end module foo
>
> Index: gcc/testsuite/gfortran.dg/pr39666-2.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/pr39666-2.f90.orig
> --- gcc/testsuite/gfortran.dg/pr39666-2.f90
> ***************
> *** 2,8 ****
> ! { dg-do compile }
> ! { dg-options "-O2 -Wuninitialized" }
>
> ! FUNCTION f(n) ! { dg-warning "may be used uninitialized" }
> INTEGER, INTENT(in) :: n
> REAL :: f
>
> --- 2,8 ----
> ! { dg-do compile }
> ! { dg-options "-O2 -Wuninitialized" }
>
> ! FUNCTION f(n)
> INTEGER, INTENT(in) :: n
> REAL :: f
>
> *************** FUNCTION f(n) ! { dg-warning "may be use
> *** 11,14 ****
> CASE (0); f = 0.0
> CASE (2:); f = 1.0
> END SELECT
> ! END FUNCTION
> --- 11,14 ----
> CASE (0); f = 0.0
> CASE (2:); f = 1.0
> END SELECT
> ! END FUNCTION ! { dg-warning "may be used uninitialized" }
> Index: gcc/testsuite/objc.dg/attributes/method-noreturn-1.m
> ===================================================================
> *** gcc/testsuite/objc.dg/attributes/method-noreturn-1.m.orig
> --- gcc/testsuite/objc.dg/attributes/method-noreturn-1.m
> ***************
> *** 18,28 ****
> + (id) method1
> {
> return self; /* { dg-warning "function declared .noreturn. has a .return. statement" } */
> ! } /* { dg-warning ".noreturn. function does return" } */
> - (id) method2
> {
> return self; /* { dg-warning "function declared .noreturn. has a .return. statement" } */
> ! } /* { dg-warning ".noreturn. function does return" } */
> + (id) method3
> {
> abort ();
> --- 18,28 ----
> + (id) method1
> {
> return self; /* { dg-warning "function declared .noreturn. has a .return. statement" } */
> ! } /* { dg-warning ".noreturn. function does return" "" { target *-*-* } 20 } */
> - (id) method2
> {
> return self; /* { dg-warning "function declared .noreturn. has a .return. statement" } */
> ! } /* { dg-warning ".noreturn. function does return" "" { target *-*-* } 24 } */
> + (id) method3
> {
> abort ();
>
>
--
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] lower gimple: Sustain line number info for returns if possible
2011-02-08 16:28 ` Andreas Krebbel
2011-02-08 16:43 ` Richard Guenther
@ 2011-02-09 19:23 ` Eric Botcazou
1 sibling, 0 replies; 9+ messages in thread
From: Eric Botcazou @ 2011-02-09 19:23 UTC (permalink / raw)
To: Andreas Krebbel; +Cc: gcc-patches, H.J. Lu, rguenther
[-- Attachment #1: Type: text/plain, Size: 406 bytes --]
> this should fix the testsuite regressions.
Here are the missing adjustement for Objective-C++ and Ada. Applied.
2011-02-09 Eric Botcazou <ebotcazou@adacore.com>
PR middle-end/47646
* gnat.dg/uninit_func.adb: Adjust dg directive.
2011-02-09 Dominique Dhumieres <dominiq@lps.ens.fr>
PR middle-end/47646
* obj-c++.dg/attributes/method-noreturn-1.mm: Adjust dg directives.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-diff, Size: 1399 bytes --]
Index: gnat.dg/uninit_func.adb
===================================================================
--- gnat.dg/uninit_func.adb (revision 169914)
+++ gnat.dg/uninit_func.adb (working copy)
@@ -2,12 +2,12 @@
-- { dg-options "-O -Wall" }
function uninit_func (A, B : Boolean) return Boolean is
- C : Boolean; -- { dg-warning "may be used uninitialized" }
+ C : Boolean;
begin
if A then
C := False;
elsif B then
C := True;
end if;
- return C;
+ return C; -- { dg-warning "may be used uninitialized" }
end;
Index: obj-c++.dg/attributes/method-noreturn-1.mm
===================================================================
--- obj-c++.dg/attributes/method-noreturn-1.mm (revision 169914)
+++ obj-c++.dg/attributes/method-noreturn-1.mm (working copy)
@@ -18,11 +18,11 @@
+ (id) method1
{
return self; /* { dg-warning "function declared .noreturn. has a .return. statement" } */
-} /* { dg-warning ".noreturn. function does return" } */
+} /* { dg-warning ".noreturn. function does return" "" { target *-*-* } 20 } */
- (id) method2
{
return self; /* { dg-warning "function declared .noreturn. has a .return. statement" } */
-} /* { dg-warning ".noreturn. function does return" } */
+} /* { dg-warning ".noreturn. function does return" "" { target *-*-* } 24 } */
+ (id) method3
{
abort ();
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-02-09 19:23 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-07 14:40 [PATCH] lower gimple: Sustain line number info for returns if possible Andreas Krebbel
2011-02-07 15:21 ` Richard Guenther
2011-02-07 18:15 ` Eric Botcazou
2011-02-08 10:43 ` Richard Guenther
2011-02-08 14:57 ` H.J. Lu
2011-02-08 16:28 ` Andreas Krebbel
2011-02-08 16:43 ` Richard Guenther
2011-02-09 19:23 ` Eric Botcazou
2011-02-08 16:33 ` Andreas Krebbel
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).