On Sat, 2023-08-26 at 14:22 +0200, priour...@gmail.com wrote:

> From: benjamin priour <priour...@gmail.com>
> 
> Hi,
> 
> Updated version of the patch, regstrapping the changes described in
> https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628455.html.
> 
> Regstrapped off trunk 66be6ed81f369573824f1a8f5a3538a63472292f
> on x86_64-linux-gnu.
> 
> OK for trunk ?

Thanks for the v2 patch.

This is almost ready, some minor nits below...

[...snip...]

> 
> gcc/analyzer/ChangeLog:
> 
>       analyzer/PR 96395

This should be PR analyzer/96395.

>       * analyzer.h (class known_function): Add virtual casts
>       to builtin_known_function.
>       (class builtin_known_function): New subclass of known_function
>       for builtins.

[...snip...]
 
> 
> gcc/testsuite/ChangeLog:
> 
>       analyzer/PR 96395

Likewise here.

>       * gcc.dg/analyzer/aliasing-3.c: Moved to...
>       * c-c++-common/analyzer/aliasing-3.c: ...here.
>       * gcc.dg/analyzer/aliasing-pr106473.c: Moved to...
>       * c-c++-common/analyzer/aliasing-pr106473.c: ...here.

[...snip...]
 
> diff --git a/gcc/analyzer/analyzer.h b/gcc/analyzer/analyzer.h
> index 93a28b4b5cf..d42771f1e20 100644
> --- a/gcc/analyzer/analyzer.h
> +++ b/gcc/analyzer/analyzer.h

[...snip...]

> @@ -279,6 +283,26 @@ public:
>    {
>      return;
>    }
> +
> +  virtual const builtin_known_function *
> +  dyn_cast_builtin_kf () const { return NULL; }
> +  virtual builtin_known_function *
> +  dyn_cast_builtin_kf () { return NULL; }

As noted in the review of v1, I don't think we ever work with non-const
known_function pointers, so we don't need the non-const version of the
vfunc.

[...snip...]

> diff --git a/gcc/testsuite/c-c++-common/analyzer/pr61861.c 
> b/gcc/testsuite/c-c++-common/analyzer/pr61861.c
> new file mode 100644
> index 00000000000..bb9e039ebd5
> --- /dev/null
> +++ b/gcc/testsuite/c-c++-common/analyzer/pr61861.c
> @@ -0,0 +1,3 @@
> +/* { dg-additional-options "-Wno-int-conversion" } */
> +/* { dg-skip-if "-Wno-int-conversion for C++" { c++ } } */
> +#include "../../gcc.dg/pr61861.c"

For tests like this that aren't going to be portable to C++, let's keep
it in the gcc.dg subdirectory, with a suitable comment, rather than
moving them and having a dg-skip-if on it.

Perhaps:

/* C only: -Wno-int-conversion is not valid for C++.  */

That way we can easily grep for the absence of "C only" when checking
to see which analyzer tests below gcc.dg still need considering for
moving below c-c++-common.  The string "C only" is conveniently short.

[...snip...]

> diff --git a/gcc/testsuite/gcc.dg/analyzer/pr95152-4.c 
> b/gcc/testsuite/c-c++-common/analyzer/pr95152-4.c
> similarity index 55%
> rename from gcc/testsuite/gcc.dg/analyzer/pr95152-4.c
> rename to gcc/testsuite/c-c++-common/analyzer/pr95152-4.c
> index f2a72cad01c..5ebbae85aee 100644
> --- a/gcc/testsuite/gcc.dg/analyzer/pr95152-4.c
> +++ b/gcc/testsuite/c-c++-common/analyzer/pr95152-4.c
> @@ -1,4 +1,6 @@
> +/* { dg-skip-if "'-Wno-pointer-to-int-cast' invalid for C++" { c++ } } */
>  /* { dg-additional-options "-Wno-pointer-to-int-cast" } */

Likewise here.

[...snip...]

> diff --git a/gcc/testsuite/gcc.dg/analyzer/pr95152-5.c 
> b/gcc/testsuite/c-c++-common/analyzer/pr95152-5.c
> similarity index 61%
> rename from gcc/testsuite/gcc.dg/analyzer/pr95152-5.c
> rename to gcc/testsuite/c-c++-common/analyzer/pr95152-5.c
> index 604b78458c7..fbc4753e0b4 100644
> --- a/gcc/testsuite/gcc.dg/analyzer/pr95152-5.c
> +++ b/gcc/testsuite/c-c++-common/analyzer/pr95152-5.c
> @@ -1,3 +1,4 @@
> +/* { dg-skip-if "'-Wno-incompatible-pointer-types' invalid for C++" { c++ } 
> } */
>  /* { dg-additional-options "-Wno-incompatible-pointer-types" } */
>  void foo(void)
>  {

Likewise here.

[...snip...]

> diff --git a/gcc/testsuite/gcc.dg/analyzer/write-to-function-1.c 
> b/gcc/testsuite/c-c++-common/analyzer/write-to-function-1.c
> similarity index 81%
> rename from gcc/testsuite/gcc.dg/analyzer/write-to-function-1.c
> rename to gcc/testsuite/c-c++-common/analyzer/write-to-function-1.c
> index c1bece632ce..dd4adc13141 100644
> --- a/gcc/testsuite/gcc.dg/analyzer/write-to-function-1.c
> +++ b/gcc/testsuite/c-c++-common/analyzer/write-to-function-1.c
> @@ -1,3 +1,5 @@
> +/* { dg-skip-if "c++ does not allow for conversion from function pointer to 
> 'void *'" { c++ } } */
> +

Likewise here.

[...snip...]

> diff --git a/gcc/testsuite/gcc.dg/analyzer/pr104369-1.c 
> b/gcc/testsuite/gcc.dg/analyzer/pr104369-1.c
> index c05137bb219..788a2059013 100644
> --- a/gcc/testsuite/gcc.dg/analyzer/pr104369-1.c
> +++ b/gcc/testsuite/gcc.dg/analyzer/pr104369-1.c
> @@ -1,5 +1,8 @@
>  /* { dg-additional-options "-Wno-analyzer-too-complex -Wno-analyzer-fd-leak" 
> } */
>  // TODO: remove need for these options
> +/* This test needs not be moved to c-c++-common/analyzer as C++
> +   does not support transparent_union. */
> +

Perhaps update this comment to:

/* C only: C++ does not support transparent_union.    */

so that we can grep for (the absence) of "C only".

and similarly for the other testfiles where you add similar comments? 
These are:

  pr104369-2.c
  sprintf-1.c

[...snip...]

OK for trunk with the above nits fixed (i.e. I trust you to go ahead
and push the v3 patch without another review once you fix the above and
check that it builds)

Thanks again for the updated patch
Dave

Reply via email to