diff options
author | Daniel Bertalan <dani@danielbertalan.dev> | 2024-07-09 23:34:46 +0200 |
---|---|---|
committer | Iain Sandoe <iains@gcc.gnu.org> | 2024-07-12 16:56:06 +0100 |
commit | 08776bef53835ff6318ecfeade8f6c6896ffd81f (patch) | |
tree | 21e181804e14db46da7c78fcdfbb9642b1105048 /gcc/analyzer/infinite-recursion.cc | |
parent | 6e7053a641393211f52c176e540c8922288ab8db (diff) | |
download | gcc-08776bef53835ff6318ecfeade8f6c6896ffd81f.zip gcc-08776bef53835ff6318ecfeade8f6c6896ffd81f.tar.gz gcc-08776bef53835ff6318ecfeade8f6c6896ffd81f.tar.bz2 |
Fix Xcode 16 build break with NULL != nullptr
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 <stddef.h>
#define NULL nullptr
#include <stddef.h>
NULL
The relevant libc++ change is here:
https://github.com/llvm/llvm-project/commit/2950283dddab03c183c1be2d7de9d4999cc86131
Filed as FB14261859 to Apple and added a comment about it on LLVM PR
86843.
This fixes the cases in --enable-languages=c,c++,objc,obj-c++,rust build
where NULL being an integral constant instead of a null pointer literal
(therefore no longer implicitly converting to a pointer when used as a
template function's argument) caused issues.
gcc/value-pointer-equiv.cc:65:43: error: no viable conversion from `pair<typename __unwrap_ref_decay<long>::type, typename __unwrap_ref_decay<long>::type>' to 'const pair<tree, tree>'
65 | const std::pair <tree, tree> 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/rust/ChangeLog:
* metadata/rust-imports.cc (Import::try_package_in_directory):
Change NULL to nullptr.
gcc/ChangeLog:
* value-pointer-equiv.cc: Change NULL to nullptr.
Signed-off-by: Daniel Bertalan <dani@danielbertalan.dev>
Diffstat (limited to 'gcc/analyzer/infinite-recursion.cc')
-rw-r--r-- | gcc/analyzer/infinite-recursion.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/analyzer/infinite-recursion.cc b/gcc/analyzer/infinite-recursion.cc index ef8ae90..885f9a8 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 |