On Jun 05 2020, Martin Sebor via Gcc-patches wrote:

> --- /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 }

Please give these tests unique names.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

Reply via email to