diff options
author | Jason Merrill <jason@redhat.com> | 2024-11-22 12:00:20 +0100 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2025-01-10 11:37:11 -0500 |
commit | e86daddbde93b4b508f0957e9aac0b935f99ed93 (patch) | |
tree | 224b2877923f5a5106433ee1236142b115c6288b /gcc | |
parent | 9193641d1695293006ed0b818bb4161a1b6fbed2 (diff) | |
download | gcc-e86daddbde93b4b508f0957e9aac0b935f99ed93.zip gcc-e86daddbde93b4b508f0957e9aac0b935f99ed93.tar.gz gcc-e86daddbde93b4b508f0957e9aac0b935f99ed93.tar.bz2 |
c++: modules and DECL_REPLACEABLE_P
We need to remember that the ::operator new is replaceable to avoid a bogus
error about __builtin_operator_new finding a non-replaceable function.
This affected __get_temporary_buffer in stl_tempbuf.h.
gcc/cp/ChangeLog:
* module.cc (trees_out::core_bools): Write replaceable_operator.
(trees_in::core_bools): Read it.
gcc/testsuite/ChangeLog:
* g++.dg/modules/operator-2_a.C: New test.
* g++.dg/modules/operator-2_b.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/module.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/operator-2_a.C | 14 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/operator-2_b.C | 8 |
3 files changed, 24 insertions, 0 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 7288c46..4fbe522 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -5640,6 +5640,7 @@ trees_out::core_bools (tree t, bits_out& bits) WB (t->function_decl.has_debug_args_flag); WB (t->function_decl.versioned_function); + WB (t->function_decl.replaceable_operator); /* decl_type is a (misnamed) 2 bit discriminator. */ unsigned kind = t->function_decl.decl_type; @@ -5796,6 +5797,7 @@ trees_in::core_bools (tree t, bits_in& bits) RB (t->function_decl.has_debug_args_flag); RB (t->function_decl.versioned_function); + RB (t->function_decl.replaceable_operator); /* decl_type is a (misnamed) 2 bit discriminator. */ unsigned kind = 0; diff --git a/gcc/testsuite/g++.dg/modules/operator-2_a.C b/gcc/testsuite/g++.dg/modules/operator-2_a.C new file mode 100644 index 0000000..0b1f6e8 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/operator-2_a.C @@ -0,0 +1,14 @@ +// { dg-additional-options -fmodules } +// { dg-module-cmi M } + +module; + +#include <new> + +export module M; + +export template <class T> +inline T* alloc (__SIZE_TYPE__ n) +{ + return (T*) __builtin_operator_new (n * sizeof (T), std::nothrow_t{}); +}; diff --git a/gcc/testsuite/g++.dg/modules/operator-2_b.C b/gcc/testsuite/g++.dg/modules/operator-2_b.C new file mode 100644 index 0000000..fb21ccb --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/operator-2_b.C @@ -0,0 +1,8 @@ +// { dg-additional-options -fmodules } + +import M; + +int main() +{ + int *p = alloc<int>(42); +} |