+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.
+
2011-02-08 Richard Guenther <rguenther@suse.de>
PR middle-end/47639
int g(void) {
return 1; /* { dg-warning "function declared 'noreturn' has a 'return' statement" } */
-} /* { dg-warning "'noreturn' function does return" } */
+} /* { dg-warning "'noreturn' function does return" "" { target *-*-* } 12 } */
int g2(void) {
h();
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 } */
+} /* { dg-warning "'noreturn' function does return" "" { target c } 27 } */
int vg2(void) {
h();
int
foo (int i)
{
- int j; // { dg-warning "may be used uninitialized" }
+ int j;
switch (i)
{
case -__INT_MAX__ - 1 ... -1:
j = 4;
break;
}
- return j;
+ return j; // { dg-warning "may be used uninitialized" }
}
foo5(void)
{
return; /* { dg-warning "'noreturn' has a 'return' statement" "detect invalid return" } */
-} /* { dg-warning "function does return" "detect return from noreturn" } */
+} /* { dg-warning "function does return" "detect return from noreturn" { target c } 37 } */
extern void foo6(void);
void
int
foo (int i)
{
- int j; /* { dg-warning "may be used uninitialized" } */
+ int j;
switch (i)
{
case -__INT_MAX__ - 1 ... -1:
j = 4;
break;
}
- return j;
+ return j; /* { dg-warning "may be used uninitialized" } */
}
int foo2( void ) {
- int rc; /* { dg-warning "'rc' is used uninitialized in this function" } */
- return rc;
+ int rc;
+ return rc; /* { dg-warning "'rc' is used uninitialized in this function" } */
*&rc = 0;
}
contains
- function baz(arg) result(res) ! { dg-warning "res.yr' may be" "PR45505" { xfail ilp32 } }
+ 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
else
res = arg
end if
- end function baz ! { dg-bogus "res.yr' may be" "PR45505" { xfail ilp32 } }
+ end function baz ! { dg-warning "res.yr' may be" "PR45505" { xfail ilp32 } }
end module foo
! { dg-do compile }
! { dg-options "-O2 -Wuninitialized" }
-FUNCTION f(n) ! { dg-warning "may be used uninitialized" }
+FUNCTION f(n)
INTEGER, INTENT(in) :: n
REAL :: f
CASE (0); f = 0.0
CASE (2:); f = 1.0
END SELECT
-END FUNCTION
+END FUNCTION ! { dg-warning "may be used uninitialized" }
+ (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 ();