diff mbox

Apply attribute returns_nonnull in libiberty

Message ID alpine.DEB.2.02.1310112334540.4994@stedding.saclay.inria.fr
State New
Headers show

Commit Message

Marc Glisse Oct. 11, 2013, 11:21 p.m. UTC
The gcc-specific part now. Bootstrap+testsuite on x86_64-unknown-linux-gnu 
together with the libiberty patch (well, 
libgomp.graphite/force-parallel-4.c failed, but that randomly happens).

2013-10-12  Marc Glisse  <marc.glisse@inria.fr>

 	PR tree-optimization/58689
 	* system.h (concat, reconcat, choose_temp_base, xmalloc, xrealloc,
 	xcalloc, xstrdup, xstrndup, xmemdup, pex_init): Mark with attribute
 	returns_nonnull.

Comments

DJ Delorie Oct. 12, 2013, 12:31 a.m. UTC | #1
Alternatively, you could ask the other projects if they're ok with
changing the xmalloc rule...
Marc Glisse Oct. 12, 2013, 7:50 a.m. UTC | #2
On Fri, 11 Oct 2013, DJ Delorie wrote:

> Alternatively, you could ask the other projects if they're ok with
> changing the xmalloc rule...

Is there an official list where all the users of libiberty can be 
contacted?
DJ Delorie Oct. 14, 2013, 5:15 p.m. UTC | #3
I don't think there's an official list, but if you ask gdb, binutils,
newlib, and sid (I think), you've probably got it covered.  Basically,
everything in the src/ repository.
Tom Tromey Oct. 14, 2013, 5:47 p.m. UTC | #4
DJ> I don't think there's an official list, but if you ask gdb, binutils,
DJ> newlib, and sid (I think), you've probably got it covered.  Basically,
DJ> everything in the src/ repository.

FWIW, gdb doesn't mind.  While gdb does override xmalloc, it does so in
a way that avoids NULL returns.

Tom
Jeff Law Oct. 15, 2013, 7:03 p.m. UTC | #5
On 10/11/13 17:21, Marc Glisse wrote:
> The gcc-specific part now. Bootstrap+testsuite on
> x86_64-unknown-linux-gnu together with the libiberty patch (well,
> libgomp.graphite/force-parallel-4.c failed, but that randomly happens).
>
> 2013-10-12  Marc Glisse  <marc.glisse@inria.fr>
>
>      PR tree-optimization/58689
>      * system.h (concat, reconcat, choose_temp_base, xmalloc, xrealloc,
>      xcalloc, xstrdup, xstrndup, xmemdup, pex_init): Mark with attribute
>      returns_nonnull.
OK.
jeff
Marc Glisse Oct. 15, 2013, 7:25 p.m. UTC | #6
On Tue, 15 Oct 2013, Jeff Law wrote:

> On 10/11/13 17:21, Marc Glisse wrote:
>> The gcc-specific part now. Bootstrap+testsuite on
>> x86_64-unknown-linux-gnu together with the libiberty patch (well,
>> libgomp.graphite/force-parallel-4.c failed, but that randomly happens).
>> 
>> 2013-10-12  Marc Glisse  <marc.glisse@inria.fr>
>>
>>      PR tree-optimization/58689
>>      * system.h (concat, reconcat, choose_temp_base, xmalloc, xrealloc,
>>      xcalloc, xstrdup, xstrndup, xmemdup, pex_init): Mark with attribute
>>      returns_nonnull.
> OK.
> jeff

Thanks.

I am going to wait a bit though. I sent an email to all libiberty users, 
and if none of them complains, I'd rather go with the original patch:

http://gcc.gnu.org/ml/gcc-patches/2013-10/msg00817.html
diff mbox

Patch

Index: gcc/system.h
===================================================================
--- gcc/system.h	(revision 203463)
+++ gcc/system.h	(working copy)
@@ -645,20 +645,40 @@  extern int vsnprintf (char *, size_t, co
 #endif
 
 /* Do not introduce a gmp.h dependency on the build system.  */
 #ifndef GENERATOR_FILE
 #include <gmp.h>
 #endif
 
 /* Get libiberty declarations.  */
 #include "libiberty.h"
 
+/* Add attributes that libiberty doesn't want to add globally.  */
+#if GCC_VERSION >= 4009
+# ifdef __cplusplus
+extern "C" {
+# endif
+__typeof (concat) concat ATTRIBUTE_RETURNS_NONNULL;
+__typeof (reconcat) reconcat ATTRIBUTE_RETURNS_NONNULL;
+__typeof (choose_temp_base) choose_temp_base ATTRIBUTE_RETURNS_NONNULL;
+__typeof (xmalloc) xmalloc ATTRIBUTE_RETURNS_NONNULL;
+__typeof (xrealloc) xrealloc ATTRIBUTE_RETURNS_NONNULL;
+__typeof (xcalloc) xcalloc ATTRIBUTE_RETURNS_NONNULL;
+__typeof (xstrdup) xstrdup ATTRIBUTE_RETURNS_NONNULL;
+__typeof (xstrndup) xstrndup ATTRIBUTE_RETURNS_NONNULL;
+__typeof (xmemdup) xmemdup ATTRIBUTE_RETURNS_NONNULL;
+__typeof (pex_init) pex_init ATTRIBUTE_RETURNS_NONNULL;
+# ifdef __cplusplus
+}
+# endif
+#endif
+
 #undef FFS  /* Some systems predefine this symbol; don't let it interfere.  */
 #undef FLOAT /* Likewise.  */
 #undef ABS /* Likewise.  */
 #undef PC /* Likewise.  */
 
 /* Provide a default for the HOST_BIT_BUCKET.
    This suffices for POSIX-like hosts.  */
 
 #ifndef HOST_BIT_BUCKET
 #define HOST_BIT_BUCKET "/dev/null"