From patchwork Wed Jul 10 06:59:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Bertalan X-Patchwork-Id: 1958731 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=danielbertalan.dev header.i=@danielbertalan.dev header.a=rsa-sha256 header.s=protonmail3 header.b=JXp4c8eI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WJpf3441vz1yNy for ; Wed, 10 Jul 2024 17:00:26 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B3B5C3870C07 for ; Wed, 10 Jul 2024 07:00:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-4323.proton.ch (mail-4323.proton.ch [185.70.43.23]) by sourceware.org (Postfix) with ESMTPS id B42C73850204 for ; Wed, 10 Jul 2024 06:59:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B42C73850204 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=danielbertalan.dev Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=danielbertalan.dev ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B42C73850204 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=185.70.43.23 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720594799; cv=none; b=cUMngzARpkrI57Im8nl5+MTU8x0vsX7moYNt/l4OHgPILr+maIKNZbuuhf9FygRP8zNFadF5qJTTrd90hJFceOv8dgvWY7CkNfsVFP6hclWYP4ACvzT2eebE7nS8ij2OJhtVYdY4hUtleqmTG5D3xeBpH+jprdjZ1R8W6qZbIJI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720594799; c=relaxed/simple; bh=xzt5CQ6Qsu8HpwW//Ycn9YJx71bOm5Z+jGMzYqQUqHw=; h=DKIM-Signature:Date:To:From:Subject:Message-ID:MIME-Version; b=q9t18xEENkcJFGQpCg5z5XyZkogv8LcZdhfifEQdWSqsQMDLesUIe8tX1ece0VivfbRve8ZFOk9wjiWRusKQHNRIz640+VNBareSltEuRNHv7X8IxVKA1BHvKjdsXoUvjISDMvSA6qeBPTFw7npwUxkvMp5sT7b0oTHyq/einkc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=danielbertalan.dev; s=protonmail3; t=1720594794; x=1720853994; bh=FMe6AyZyEVNRw5QW+R04f+GNtpRUzPrQJlY+PqGSbEE=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=JXp4c8eItIbUNJZMQeluD8JVDHF/tSaWe1JRz64EejL52Cn0mrM2xyuDXNmAF/Wtl r2DYlYlh3BoTSVlGRTbqIpAARLvVbldTL+tp7aO4L3E0Vqz/KW+Mgg4MsBer3n7W85 ns7oZCYN4vjimfw4I2LduTA3f59KWyr8Ov02XsQk2xFsn65Kqeo2tpfypwDpYCPrNy dxPMug3DlCWigP9ABJi9dAnjJeT//27pQ4bRo582e/kpRUtwAoYB4wKL2ZHufwMVaK c8zsvNVtpoNDBt2o2/Wvu2eXEX5QmMkyXLYbQZ87WI0rTyNzLW/XCg7d5gIk6vznoK 30wLwiJ+rhElg== Date: Wed, 10 Jul 2024 06:59:49 +0000 To: gcc-patches@gcc.gnu.org From: dani@danielbertalan.dev Cc: Daniel Bertalan Subject: [PATCH] Fix Xcode 16 build break with NULL != nullptr Message-ID: <20240710065938.35838-1-dani@danielbertalan.dev> Feedback-ID: 20340505:user:proton X-Pm-Message-ID: 363ceae0def470b179f1b199f99fb9e3474f5179 MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Daniel Bertalan As of Xcode 16 beta 2 with the macOS 15 SDK, each re-inclusion of the stddef.h header causes the NULL macro in C++ to be re-defined to an integral constant (__null). This makes the workaround in d59a576b8 ("Redefine NULL to nullptr") ineffective, as other headers that are typically included after system.h (such as obstack.h) do include stddef.h too. This can be seen by running the sample below through `clang++ -E` #include #define NULL nullptr #include NULL The relevant libc++ change is here: https://github.com/llvm/llvm-project/commit/2950283dddab03c183c1be2d7de9d4999cc86131 This commit fixes the instances where NULL being an integral constant instead of a null pointer literal (such as no longer implicitly converting to a pointer when used as a template function's argument). gcc/value-pointer-equiv.cc:65:43: error: no viable conversion from `pair::type, typename __unwrap_ref_decay::type>' to 'const pair' 65 | const std::pair m_marker = std::make_pair (NULL, NULL); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ As noted in the previous commit though, the proper solution would be to phase out the usages of NULL in GCC's C++ source code. gcc/analyzer/ChangeLog: * diagnostic-manager.cc (saved_diagnostic::saved_diagnostic): Change NULL to nullptr. (struct null_assignment_sm_context): Likewise. * infinite-loop.cc: Likewise. * infinite-recursion.cc: Likewise. * varargs.cc (va_list_state_machine::on_leak): Likewise. gcc/ChangeLog: * value-pointer-equiv.cc: Change NULL to nullptr. --- gcc/analyzer/diagnostic-manager.cc | 18 +++++++++--------- gcc/analyzer/infinite-loop.cc | 2 +- gcc/analyzer/infinite-recursion.cc | 2 +- gcc/analyzer/varargs.cc | 2 +- gcc/value-pointer-equiv.cc | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc index fe943ac61c9e..51304b0795b6 100644 --- a/gcc/analyzer/diagnostic-manager.cc +++ b/gcc/analyzer/diagnostic-manager.cc @@ -679,12 +679,12 @@ saved_diagnostic::saved_diagnostic (const state_machine *sm, m_stmt (ploc.m_stmt), /* stmt_finder could be on-stack; we want our own copy that can outlive that. */ - m_stmt_finder (ploc.m_finder ? ploc.m_finder->clone () : NULL), + m_stmt_finder (ploc.m_finder ? ploc.m_finder->clone () : nullptr), m_loc (ploc.m_loc), m_var (var), m_sval (sval), m_state (state), - m_d (std::move (d)), m_trailing_eedge (NULL), + m_d (std::move (d)), m_trailing_eedge (nullptr), m_idx (idx), - m_best_epath (NULL), m_problem (NULL), + m_best_epath (nullptr), m_problem (nullptr), m_notes () { /* We must have an enode in order to be able to look for paths @@ -1800,10 +1800,10 @@ public: stmt, stack_depth, sm, - NULL, + nullptr, src_sm_val, dst_sm_val, - NULL, + nullptr, dst_state, src_node)); return false; @@ -1993,9 +1993,9 @@ struct null_assignment_sm_context : public sm_context m_sm, var_new_sval, from, to, - NULL, + nullptr, *m_new_state, - NULL)); + nullptr)); } void set_next_state (const gimple *stmt, @@ -2019,9 +2019,9 @@ struct null_assignment_sm_context : public sm_context m_sm, sval, from, to, - NULL, + nullptr, *m_new_state, - NULL)); + nullptr)); } void warn (const supernode *, const gimple *, diff --git a/gcc/analyzer/infinite-loop.cc b/gcc/analyzer/infinite-loop.cc index 8ba8e70acffc..6ac0a5b373d8 100644 --- a/gcc/analyzer/infinite-loop.cc +++ b/gcc/analyzer/infinite-loop.cc @@ -240,7 +240,7 @@ public: enode->get_function ()->decl, enode->get_stack_depth ()), enode, - NULL, NULL, NULL)); + nullptr, nullptr, nullptr)); logger *logger = emission_path->get_logger (); diff --git a/gcc/analyzer/infinite-recursion.cc b/gcc/analyzer/infinite-recursion.cc index ef8ae90ab08e..885f9a8a9417 100644 --- a/gcc/analyzer/infinite-recursion.cc +++ b/gcc/analyzer/infinite-recursion.cc @@ -196,7 +196,7 @@ public: m_callee_fndecl, m_new_entry_enode->get_stack_depth ()), enode, - NULL, NULL, NULL)); + nullptr, nullptr, nullptr)); } /* Reject paths in which conjured svalues have affected control flow diff --git a/gcc/analyzer/varargs.cc b/gcc/analyzer/varargs.cc index c197883673d6..734323e6f789 100644 --- a/gcc/analyzer/varargs.cc +++ b/gcc/analyzer/varargs.cc @@ -631,7 +631,7 @@ va_list_state_machine::on_va_end (sm_context &sm_ctxt, std::unique_ptr va_list_state_machine::on_leak (tree var) const { - return make_unique (*this, NULL, var); + return make_unique (*this, nullptr, var); } } // anonymous namespace diff --git a/gcc/value-pointer-equiv.cc b/gcc/value-pointer-equiv.cc index bfc940ec9915..f8564536c308 100644 --- a/gcc/value-pointer-equiv.cc +++ b/gcc/value-pointer-equiv.cc @@ -62,7 +62,7 @@ public: private: auto_vec> m_stack; auto_vec m_replacements; - const std::pair m_marker = std::make_pair (NULL, NULL); + const std::pair m_marker = std::make_pair(nullptr, nullptr); }; ssa_equiv_stack::ssa_equiv_stack ()