gcc/libstdc++-v3/libsupc++
Jakub Jelinek 80e5be0c7f ibstdc++: Add some further attributes to ::operator new in <new>
I've noticed alloc_align attribute is missing on the non-vector
::operator new with std::align_val_t and const std::nothrow_t&
arguments, this patch adds it.  The last hunk is just
an attempt to make the line shorter.
The first hunk originally added also __alloc_size__ (1) attribute,
but seems that regresses
FAIL: g++.dg/tm/pr46270.C  -std=gnu++98 (test for excess errors)
with
Excess errors:
.../libstdc++-v3/libsupc++/new:137:26: warning: new declaration 'void* operator new(std::size_t)' ambiguates built-in declaration 'void* operator new(long unsigned int)
+transaction_safe' [-Wbuiltin-declaration-mismatch]
.../libstdc++-v3/libsupc++/new:140:26: warning: new declaration 'void* operator new [](std::size_t)' ambiguates built-in declaration 'void* operator new [](long unsigned int)
+transaction_safe' [-Wbuiltin-declaration-mismatch]
I must say I have no clue why that happens only in C++98 (C++11 and
above are quiet) and why only with -fgnu-tm, tried to debug that but
am lost.  It is some conflict with the predeclared ::operator new, but
those clearly do have the externally_visible attribute, and alloc_size (1)
attributes:
     extvisattr = build_tree_list (get_identifier ("externally_visible"),
                                   NULL_TREE);
     newattrs = tree_cons (get_identifier ("alloc_size"),
                           build_tree_list (NULL_TREE, integer_one_node),
                           extvisattr);
     newtype = cp_build_type_attribute_variant (ptr_ftype_sizetype, newattrs);
     newtype = build_exception_variant (newtype, new_eh_spec);
...
    tree opnew = push_cp_library_fn (NEW_EXPR, newtype, 0);
    DECL_IS_MALLOC (opnew) = 1;
    DECL_SET_IS_OPERATOR_NEW (opnew, true);
    DECL_IS_REPLACEABLE_OPERATOR (opnew) = 1;
and at C++98 I think libstdc++ doesn't add transaction_safe attribute:
 // Conditionally enable annotations for the Transactional Memory TS on C++11.
 // Most of the following conditions are due to limitations in the current
 // implementation.
 #if __cplusplus >= 201103L && _GLIBCXX_USE_CXX11_ABI                    \
   && _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201500L     \
   &&  !_GLIBCXX_FULLY_DYNAMIC_STRING && _GLIBCXX_USE_WEAK_REF           \
   && _GLIBCXX_USE_ALLOCATOR_NEW
 #define _GLIBCXX_TXN_SAFE transaction_safe
 #define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic
 #else
 #define _GLIBCXX_TXN_SAFE
 #define _GLIBCXX_TXN_SAFE_DYN
 #endif
push_cp_library_fn adds transaction_safe attribute whenever -fgnu-tm
is used, regardless of the other conditionals:
   if (flag_tm)
     apply_tm_attr (fn, get_identifier ("transaction_safe"));

Anyway, omitting alloc_size (1) fixes that test and given that the
predeclared operator new already has alloc_size (1) attribute, I think it
can be safely left out.

2024-11-08  Jakub Jelinek  <jakub@redhat.com>

	* libsupc++/new (::operator new, ::operator new[]): Add malloc
	attribute where missing.  Add alloc_align attribute when
	std::align_val_t is present and where it was missing.  Formatting fix.
2024-11-08 22:07:33 +01:00
..
array_type_info.cc
atexit_arm.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
atexit_thread.cc
atomic_lockfree_defines.h libstdc++: #ifdef out #pragma GCC system_header 2024-09-25 08:20:45 -04:00
bad_alloc.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
bad_array_length.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
bad_array_new.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
bad_cast.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
bad_typeid.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
class_type_info.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
compare libstdc++: #ifdef out #pragma GCC system_header 2024-09-25 08:20:45 -04:00
cxxabi_forced.h non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
cxxabi_init_exception.h libstdc++: #ifdef out #pragma GCC system_header 2024-09-25 08:20:45 -04:00
cxxabi.h non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
del_op.cc
del_opa.cc
del_opant.cc
del_opnt.cc
del_ops.cc
del_opsa.cc
del_opv.cc
del_opva.cc
del_opvant.cc
del_opvnt.cc
del_opvs.cc
del_opvsa.cc
dyncast.cc
eh_alloc.cc
eh_arm.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
eh_atomics.h
eh_aux_runtime.cc
eh_call.cc
eh_catch.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
eh_exception.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
eh_globals.cc
eh_personality.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
eh_ptr.cc
eh_term_handler.cc
eh_term_handler.h
eh_terminate.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
eh_throw.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
eh_tm.cc
eh_type.cc
eh_unex_handler.cc libstdc++: use updated type for __unexpected_handler 2024-01-11 19:11:45 +00:00
enum_type_info.cc
exception libstdc++: #ifdef out #pragma GCC system_header 2024-09-25 08:20:45 -04:00
exception_defines.h
exception_ptr.h non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
exception.h libstdc++: #ifdef out #pragma GCC system_header 2024-09-25 08:20:45 -04:00
function_type_info.cc
fundamental_type_info.cc
guard_error.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
guard.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
hash_bytes.cc
hash_bytes.h libstdc++: #ifdef out #pragma GCC system_header 2024-09-25 08:20:45 -04:00
initializer_list libstdc++: #ifdef out #pragma GCC system_header 2024-09-25 08:20:45 -04:00
Makefile.am libstdc++, Darwin: Handle a linker warning [PR112397]. 2024-02-19 20:14:34 +00:00
Makefile.in libstdc++, Darwin: Handle a linker warning [PR112397]. 2024-02-19 20:14:34 +00:00
nested_exception.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
nested_exception.h
new ibstdc++: Add some further attributes to ::operator new in <new> 2024-11-08 22:07:33 +01:00
new_handler.cc
new_op.cc
new_opa.cc libstdc++: Fix declaration of posix_memalign for freestanding 2024-06-14 15:24:14 +01:00
new_opant.cc
new_opnt.cc
new_opv.cc
new_opva.cc
new_opvant.cc
new_opvnt.cc
pbase_type_info.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
pmem_type_info.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
pointer_type_info.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
pure.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
si_class_type_info.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
tinfo2.cc
tinfo.cc
tinfo.h non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
typeinfo libstdc++: Remove stray whitespace in #endif 2024-11-01 16:13:30 +00:00
unwind-cxx.h non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
vec.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
vmi_class_type_info.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
vterminate.cc non-gcc: Remove trailing whitespace 2024-10-25 10:03:17 +02:00
vtv_stubs.cc