From 300452d7bf1d3a0ff3f7585a1166f3d473c70556 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Fri, 5 Jun 2020 09:34:39 -0600 Subject: [PATCH] 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. --- .../c-c++-common/goacc/uninit-use-device-clause.c | 2 +- gcc/testsuite/c-c++-common/pr59223.c | 2 +- gcc/testsuite/g++.dg/warn/Wnonnull5.C | 108 +++++++++++++++++++++ gcc/testsuite/gcc.dg/pr59924.c | 2 +- gcc/testsuite/gcc.dg/ubsan/pr81981.c | 4 +- gcc/testsuite/gcc.dg/ubsan/pr89284.c | 4 +- .../gfortran.dg/goacc/uninit-use-device-clause.f95 | 2 +- 7 files changed, 116 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/warn/Wnonnull5.C 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 c5d327c..02fb99a 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 471c062..f91e4430 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 0000000..8b25d2d --- /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 1d8d52f..9063a23 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 b2636d4..8a6597c 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 0d73e8f..965225c 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 48d08a5..35310d1 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 -- 2.7.4