From: Martin Sebor Date: Fri, 5 Jun 2020 15:34:39 +0000 (-0600) Subject: Adjust text of expected warnings to g:b825a22890740f341eae566af27e18e528cd29a7. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=300452d7bf1d3a0ff3f7585a1166f3d473c70556;p=gcc.git Adjust text of expected warnings to g:b825a22890740f341eae566af27e18e528cd29a7. gcc/testsuite/ChangeLog: * c-c++-common/goacc/uninit-use-device-clause.c: Adjust. * c-c++-common/pr59223.c: Same. * g++.dg/warn/Wnonnull5.C: Same. * gcc.dg/pr59924.c: Same. * gcc.dg/ubsan/pr81981.c: Same. * gcc.dg/ubsan/pr89284.c: Same. * gfortran.dg/goacc/uninit-use-device-clause.f95: Same. --- diff --git a/gcc/testsuite/c-c++-common/goacc/uninit-use-device-clause.c b/gcc/testsuite/c-c++-common/goacc/uninit-use-device-clause.c index c5d327caf80..02fb99a1e24 100644 --- a/gcc/testsuite/c-c++-common/goacc/uninit-use-device-clause.c +++ b/gcc/testsuite/c-c++-common/goacc/uninit-use-device-clause.c @@ -8,7 +8,7 @@ foo (void) { int i; -#pragma acc host_data use_device(i) /* { dg-warning "is used uninitialized in this function" "" { xfail *-*-* } } */ +#pragma acc host_data use_device(i) /* { dg-warning "is used uninitialized" "" { xfail *-*-* } } */ { } } diff --git a/gcc/testsuite/c-c++-common/pr59223.c b/gcc/testsuite/c-c++-common/pr59223.c index 471c0625df3..f91e4430058 100644 --- a/gcc/testsuite/c-c++-common/pr59223.c +++ b/gcc/testsuite/c-c++-common/pr59223.c @@ -9,5 +9,5 @@ int foo (int x) y = 1; else if (x == 1) y = 2; - return y; /* { dg-warning "may be used uninitialized in this function" } */ + return y; /* { dg-warning "may be used uninitialized" } */ } diff --git a/gcc/testsuite/g++.dg/warn/Wnonnull5.C b/gcc/testsuite/g++.dg/warn/Wnonnull5.C new file mode 100644 index 00000000000..8b25d2d9f86 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wnonnull5.C @@ -0,0 +1,108 @@ +/* PR c++/86568 - -Wnonnull warnings should highlight the relevant argument + not the closing parenthesis. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define NONNULL __attribute__ ((nonnull)) + +#if __cplusplus < 201103L +# define nullptr __null +#endif + +struct S +{ + void + f0 (const void*) const; // { dg-message "in a call to non-static member function 'void S::f0\\(const void\\*\\) const'" } + + void + f1 (const void*) const; // { dg-message "in a call to non-static member function 'void S::f1\\(const void\\*\\) const'" } + + void + f2 (const void*) const; // { dg-message "in a call to non-static member function 'void S::f2\\(const void\\*\\) const'" } + + NONNULL void + f3 (const void*, const void*); // { dg-message "in a call to function 'void S::f3\\(const void\\*, const void\\*\\)' declared 'nonnull'" } + + NONNULL void + f4 (const void*, const void*); // { dg-message "in a call to function 'void S::f4\\(const void\\*, const void\\*\\)' declared 'nonnull'" } + + NONNULL void + f5 (const void*, const void*); // { dg-message "in a call to function 'void S::f5\\\(const void\\*, const void\\*\\)' declared 'nonnull'" } + + NONNULL void + f6 (const void*, const void*); // { dg-message "in a call to function 'void S::f6\\\(const void\\*, const void\\*\\)' declared 'nonnull'" } +}; + +void warn_nullptr_this () +{ + ((S*)nullptr)->f0 (""); // { dg-warning "3:'this' pointer null" "pr86568" { xfail *-*-* } } + // { dg-warning "this' pointer null" "pr86568" { target *-*-* } .-1 } +} + +void warn_null_this_cst () +{ + S* const null = 0; + null->f1 (""); // { dg-warning "3:'this' pointer null" } +} + +void warn_null_this_var () +{ + S* null = 0; + null->f2 (&null); // { dg-warning "3:'this' pointer null" "pr86568" { xfail *-*-* } } + // { dg-warning "'this' pointer null" "pr86568" { target *-*-* } .-1 } +} + +void warn_nullptr (S s) +{ + s.f3 (nullptr, &s); // { dg-warning "9:argument 1 null where non-null expected" "pr86568" { xfail *-*-* } } + // { dg-warning "argument 1 null where non-null expected" "pr86568" { target *-*-* } .-1 } + s.f3 (&s, nullptr); // { dg-warning "13:argument 2 null where non-null expected" "pr86568" { xfail *-*-* } } + // { dg-warning "argument 2 null where non-null expected" "pr86568" { target *-*-* } .-1 } +} + + +void warn_null_cst (S s) +{ + void* const null = 0; + s.f4 (null, &s); // { dg-warning "9:argument 1 null where non-null expected" } + s.f4 (&s, null); // { dg-warning "13:argument 2 null where non-null expected" } +} + +void warn_null_var (S s) +{ + void* null = 0; + s.f5 (null, &s); // { dg-warning "9:argument 1 null where non-null expected" "pr86568" { xfail *-*-* } } + // { dg-warning "argument 1 null where non-null expected" "pr86568" { target *-*-* } .-1 } + s.f5 (&s, null); // { dg-warning "16:argument 2 null where non-null expected" "pr86568" { xfail *-*-* } } + // { dg-warning "argument 2 null where non-null expected" "pr86568" { target *-*-* } .-1 } +} + +void warn_null_cond (S s, void *null) +{ + if (null) + return; + + s.f6 (null, &s); // { dg-warning "9:argument 1 null where non-null expected" "pr86568" { xfail *-*-* } } + // { dg-warning "argument 1 null where non-null expected" "pr86568" { target *-*-* } .-1 } + s.f6 (&s, null); // { dg-warning "13:argument 2 null where non-null expected" "pr86568" { xfail *-*-* } } + // { dg-warning "argument 2 null where non-null expected" "pr86568" { target *-*-* } .-1 } +} + + +typedef NONNULL void Fvp (const void*, const void*); + +void warn_fptr_null_cst (Fvp *p) +{ + void* const null = 0; + p (null, ""); // { dg-warning "6:argument 1 null where non-null expected" } + p ("", null); // { dg-warning "10:argument 2 null where non-null expected" } +} + +typedef NONNULL void (S::*SMemFvp) (const void*, const void*); + +void warn_memfptr_null_cst (S *p, SMemFvp pmf) +{ + void* const null = 0; + (p->*pmf) (null, ""); // { dg-warning "14:argument 1 null where non-null expected" } + (p->*pmf) ("", null); // { dg-warning "18:argument 2 null where non-null expected" } +} diff --git a/gcc/testsuite/gcc.dg/pr59924.c b/gcc/testsuite/gcc.dg/pr59924.c index 1d8d52fb079..9063a239434 100644 --- a/gcc/testsuite/gcc.dg/pr59924.c +++ b/gcc/testsuite/gcc.dg/pr59924.c @@ -21,7 +21,7 @@ foo (struct S * x, int y, int z, int w) } if (y != 0 || z != 0) { - double g = x->b + (double) e * (double) y; /* { dg-warning "may be used uninitialized in this function" } */ + double g = x->b + (double) e * (double) y; /* { dg-warning "may be used uninitialized" } */ bar (g * g); } } diff --git a/gcc/testsuite/gcc.dg/ubsan/pr81981.c b/gcc/testsuite/gcc.dg/ubsan/pr81981.c index b2636d4c934..8a6597c84c8 100644 --- a/gcc/testsuite/gcc.dg/ubsan/pr81981.c +++ b/gcc/testsuite/gcc.dg/ubsan/pr81981.c @@ -16,6 +16,6 @@ foo (int i) u[0] = i; } - v = u[0]; /* { dg-warning "may be used uninitialized in this function" } */ - return t[0]; /* { dg-warning "may be used uninitialized in this function" } */ + v = u[0]; /* { dg-warning "may be used uninitialized" } */ + return t[0]; /* { dg-warning "may be used uninitialized" } */ } diff --git a/gcc/testsuite/gcc.dg/ubsan/pr89284.c b/gcc/testsuite/gcc.dg/ubsan/pr89284.c index 0d73e8fa4a1..965225c6702 100644 --- a/gcc/testsuite/gcc.dg/ubsan/pr89284.c +++ b/gcc/testsuite/gcc.dg/ubsan/pr89284.c @@ -8,7 +8,7 @@ int foo (void) { struct A a; - if (a.i) /* { dg-warning "'a.i' is used uninitialized in this function" } */ + if (a.i) /* { dg-warning "'a.i' is used uninitialized" } */ return 1; return 0; } @@ -17,7 +17,7 @@ int bar (void) { struct A a; - if (a.a) /* { dg-warning "'a.a' is used uninitialized in this function" } */ + if (a.a) /* { dg-warning "'a.a' is used uninitialized" } */ return 1; return 0; } diff --git a/gcc/testsuite/gfortran.dg/goacc/uninit-use-device-clause.f95 b/gcc/testsuite/gfortran.dg/goacc/uninit-use-device-clause.f95 index 48d08a5a55d..35310d14c52 100644 --- a/gcc/testsuite/gfortran.dg/goacc/uninit-use-device-clause.f95 +++ b/gcc/testsuite/gfortran.dg/goacc/uninit-use-device-clause.f95 @@ -4,7 +4,7 @@ subroutine test integer, pointer :: p - !$acc host_data use_device(p) ! { dg-warning "is used uninitialized in this function" } + !$acc host_data use_device(p) ! { dg-warning "is used uninitialized" } !$acc end host_data end subroutine test