On Wed, Feb 13, 2019 at 2:54 PM Joseph Myers <jos...@codesourcery.com> wrote:
>
> On Wed, 13 Feb 2019, H.J. Lu wrote:
>
> > Like this?
>
> This patch is missing any updates to options.texi to discuss the
> interation of Negative and RejectNegative with Joined.

I will add something.

> > diff --git a/gcc/testsuite/gcc.dg/pr69471-1.c 
> > b/gcc/testsuite/gcc.dg/pr69471-1.c
> > new file mode 100644
> > index 00000000000..3eac3b5bdbc
> > --- /dev/null
> > +++ b/gcc/testsuite/gcc.dg/pr69471-1.c
> > @@ -0,0 +1,9 @@
> > +/* { dg-do compile } */
> > +/* { dg-options "-Wno-implicit-function-declaration -Wno-int-conversion 
> > -fno-builtin-free -fno-builtin-malloc" } */
> > +
> > +void *
> > +foo (void * p)
> > +{
> > +  free (p);
> > +  return malloc (p);
>
> How does this test verify that both -fno-builtin-* options are in effect?
> That is, how does it fail if you remove either or both of those options?
>

Without -fno-builtin-free -fno-builtin-malloc

[hjl@gnu-cfl-1 gcc]$ cat
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c
/* { dg-do compile } */
/* { dg-options "-Wno-implicit-function-declaration
-Wno-int-conversion -fno-builtin-free -fno-builtin-malloc" } */

void *
foo (void * p)
{
  free (p);
  return malloc (p);
}
[hjl@gnu-cfl-1 gcc]$ gcc -S -Wno-implicit-function-declaration
-Wno-int-conversion
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c:
In function ‘foo’:
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c:7:3:
warning: incompatible implicit declaration of built-in function ‘free’
   free (p);
   ^~~~
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c:7:3:
note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c:1:1:
+#include <stdlib.h>
 /* { dg-do compile } */
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c:7:3:
   free (p);
   ^~~~
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c:8:10:
warning: incompatible implicit declaration of built-in function
‘malloc’
   return malloc (p);
          ^~~~~~
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c:8:10:
note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
[hjl@gnu-cfl-1 gcc]$

Without only -fno-builtin-malloc:
[hjl@gnu-cfl-1 gcc]$ gcc -S -Wno-implicit-function-declaration
-Wno-int-conversion
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c
-fno-builtin-malloc
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c:
In function ‘foo’:
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c:7:3:
warning: incompatible implicit declaration of built-in function ‘free’
   free (p);
   ^~~~
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c:7:3:
note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c:1:1:
+#include <stdlib.h>
 /* { dg-do compile } */
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c:7:3:
   free (p);
   ^~~~
[hjl@gnu-cfl-1 gcc]$

With -fno-builtin-free -fno-builtin-malloc

[hjl@gnu-cfl-1 gcc]$ gcc -S -Wno-implicit-function-declaration
-Wno-int-conversion
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/pr69471-1.c
-fno-builtin-free -fno-builtin-malloc
[hjl@gnu-cfl-1 gcc]$

if  -fno-builtin-free is overridden by -fno-builtin-malloc, compile will fail.


H.J.
-- 
H.J.

Reply via email to