Message ID | 6defa548-2da3-6cba-0372-f1e6c6b64c81@suse.cz |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DFF473858025 for <patchwork@sourceware.org>; Fri, 6 Jan 2023 12:21:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 494313858D28 for <gcc-patches@gcc.gnu.org>; Fri, 6 Jan 2023 12:21:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 494313858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E8431249F0; Fri, 6 Jan 2023 12:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1673007686; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jI+xEh1SyPVD0tZltRz937GQohFGmrkbE+on9JA6NMg=; b=h/62xguA/42PlFWKm2/M1WyAFlvoMnGS85RvlSXR7h6RiKwrXaW7ALVsvWdxeTp/+PSU5Y d4sjMCp3QYmiA0JmPWcU63o5dIHxhQLbJANRRxIFTet8E+tfSAzr9ewnAFMcuEb/gQeJjm Kn9ui5DXbn7n5IVQe9rGFz6e5Ykdnws= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1673007686; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jI+xEh1SyPVD0tZltRz937GQohFGmrkbE+on9JA6NMg=; b=lMIsK+oLUv9/p2ZfnG+72hPGey7KcTHiNtefwa+rPA1ZkE5XIqETjsqCL0MXPAYtz/VTbB 5g+IoCduFJyWOLDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D227313596; Fri, 6 Jan 2023 12:21:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id lLR4MkYSuGOIPAAAMHmgww (envelope-from <mliska@suse.cz>); Fri, 06 Jan 2023 12:21:26 +0000 Message-ID: <6defa548-2da3-6cba-0372-f1e6c6b64c81@suse.cz> Date: Fri, 6 Jan 2023 13:21:26 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 From: =?utf-8?q?Martin_Li=C5=A1ka?= <mliska@suse.cz> Subject: [PATCH] Remove legacy pre-C++ 11 definitions To: gcc-patches@gcc.gnu.org Content-Language: en-US Cc: Jonathan Wakely <jwakely.gcc@gmail.com>, Andrew Pinski <pinskia@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
Remove legacy pre-C++ 11 definitions
|
|
Commit Message
Martin Liška
Jan. 6, 2023, 12:21 p.m. UTC
As mentioned in the PRs, both are defined in C++ 11 which is a version we depend on. Ready to be installed now? Thanks, Martin PR middle-end/108311 PR middle-end/108312 gcc/ChangeLog: * system.h (va_copy): Remove as it is defined in C++ 11. (NULL): Likewise. --- gcc/system.h | 13 ------------- 1 file changed, 13 deletions(-)
Comments
On Fri, Jan 6, 2023 at 4:21 AM Martin Liška <mliska@suse.cz> wrote: > > As mentioned in the PRs, both are defined in C++ 11 > which is a version we depend on. > > Ready to be installed now? There is another #define NULL below: /* System headers may define NULL to be an integer (e.g. 0L), which cannot be used safely in certain contexts (e.g. as sentinels). Redefine NULL to nullptr in order to make it safer. Note that this might confuse system headers, however, by convention they must not be included after this point. */ #ifdef __cplusplus #undef NULL #define NULL nullptr #endif Thanks, Andrew Pinski > > Thanks, > Martin > > PR middle-end/108311 > PR middle-end/108312 > > gcc/ChangeLog: > > * system.h (va_copy): Remove as it is defined in C++ 11. > (NULL): Likewise. > --- > gcc/system.h | 13 ------------- > 1 file changed, 13 deletions(-) > > diff --git a/gcc/system.h b/gcc/system.h > index 5eaeb9d2d03..0d06b9749e5 100644 > --- a/gcc/system.h > +++ b/gcc/system.h > @@ -31,25 +31,12 @@ along with GCC; see the file COPYING3. If not see > /* We must include stdarg.h before stdio.h. */ > #include <stdarg.h> > > -#ifndef va_copy > -# ifdef __va_copy > -# define va_copy(d,s) __va_copy (d, s) > -# else > -# define va_copy(d,s) ((d) = (s)) > -# endif > -#endif > - > #ifdef HAVE_STDDEF_H > # include <stddef.h> > #endif > > #include <stdio.h> > > -/* Define a generic NULL if one hasn't already been defined. */ > -#ifndef NULL > -#define NULL 0 > -#endif > - > /* Use the unlocked open routines from libiberty. */ > > /* Some of these are #define on some systems, e.g. on AIX to redirect > -- > 2.39.0 >
On Fri, 6 Jan 2023, 17:21 Andrew Pinski, <pinskia@gmail.com> wrote: > On Fri, Jan 6, 2023 at 4:21 AM Martin Liška <mliska@suse.cz> wrote: > > > > As mentioned in the PRs, both are defined in C++ 11 > > which is a version we depend on. > > > > Ready to be installed now? > > There is another #define NULL below: > /* System headers may define NULL to be an integer (e.g. 0L), which cannot > be > used safely in certain contexts (e.g. as sentinels). Redefine NULL to > nullptr in order to make it safer. Note that this might confuse system > headers, however, by convention they must not be included after this > point. > */ > #ifdef __cplusplus > #undef NULL > #define NULL nullptr > #endif > Seems to me that GCC code should just use nullptr directly not redefine NULL. Thanks, > Andrew Pinski > > > > > Thanks, > > Martin > > > > PR middle-end/108311 > > PR middle-end/108312 > > > > gcc/ChangeLog: > > > > * system.h (va_copy): Remove as it is defined in C++ 11. > > (NULL): Likewise. > > --- > > gcc/system.h | 13 ------------- > > 1 file changed, 13 deletions(-) > > > > diff --git a/gcc/system.h b/gcc/system.h > > index 5eaeb9d2d03..0d06b9749e5 100644 > > --- a/gcc/system.h > > +++ b/gcc/system.h > > @@ -31,25 +31,12 @@ along with GCC; see the file COPYING3. If not see > > /* We must include stdarg.h before stdio.h. */ > > #include <stdarg.h> > > > > -#ifndef va_copy > > -# ifdef __va_copy > > -# define va_copy(d,s) __va_copy (d, s) > > -# else > > -# define va_copy(d,s) ((d) = (s)) > > -# endif > > -#endif > > - > > #ifdef HAVE_STDDEF_H > > # include <stddef.h> > > #endif > > > > #include <stdio.h> > > > > -/* Define a generic NULL if one hasn't already been defined. */ > > -#ifndef NULL > > -#define NULL 0 > > -#endif > > - > > /* Use the unlocked open routines from libiberty. */ > > > > /* Some of these are #define on some systems, e.g. on AIX to redirect > > -- > > 2.39.0 > > >
On 1/6/23 19:23, Jonathan Wakely wrote:
> Seems to me that GCC code should just use nullptr directly not redefine NULL.
Sure, but that would lead to a huge patch which would rename NULL to nullptr, right?
Martin
On Mon, 9 Jan 2023 at 15:17, Martin Liška <mliska@suse.cz> wrote: > > On 1/6/23 19:23, Jonathan Wakely wrote: > > Seems to me that GCC code should just use nullptr directly not redefine NULL. > > Sure, but that would lead to a huge patch which would rename NULL to nullptr, right? Yeah, which can probably be done separately (or not done at all). I was just commenting on the comment that Andrew showed. That comment explain that nullptr is better than 0 as a null pointer constant, which is a good reason to prefer nullptr. But not a good reason to redefine NULL; in code with a minimum requirement of C++11 you can just use nullptr directly.
On 1/9/23 16:19, Jonathan Wakely wrote: > On Mon, 9 Jan 2023 at 15:17, Martin Liška <mliska@suse.cz> wrote: >> >> On 1/6/23 19:23, Jonathan Wakely wrote: >>> Seems to me that GCC code should just use nullptr directly not redefine NULL. >> >> Sure, but that would lead to a huge patch which would rename NULL to nullptr, right? > > > Yeah, which can probably be done separately (or not done at all). That would be a massive patch affecting all targets and FEs. > I was just commenting on the comment that Andrew showed. That comment > explain that nullptr is better than 0 as a null pointer constant, > which is a good reason to prefer nullptr. But not a good reason to > redefine NULL; in code with a minimum requirement of C++11 you can > just use nullptr directly. Ok, so does it mean my patch addresses what can be easily adjusted? Thanks, Martin
diff --git a/gcc/system.h b/gcc/system.h index 5eaeb9d2d03..0d06b9749e5 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -31,25 +31,12 @@ along with GCC; see the file COPYING3. If not see /* We must include stdarg.h before stdio.h. */ #include <stdarg.h> -#ifndef va_copy -# ifdef __va_copy -# define va_copy(d,s) __va_copy (d, s) -# else -# define va_copy(d,s) ((d) = (s)) -# endif -#endif - #ifdef HAVE_STDDEF_H # include <stddef.h> #endif #include <stdio.h> -/* Define a generic NULL if one hasn't already been defined. */ -#ifndef NULL -#define NULL 0 -#endif - /* Use the unlocked open routines from libiberty. */ /* Some of these are #define on some systems, e.g. on AIX to redirect