1 #define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class")))
2 #ifndef MOZ_HEAP_ALLOCATOR
3 #define MOZ_HEAP_ALLOCATOR \
4 _Pragma("GCC diagnostic push") \
5 _Pragma("GCC diagnostic ignored \"-Wgcc-compat\"") \
6 __attribute__((annotate("moz_heap_allocator"))) \
7 _Pragma("GCC diagnostic pop")
13 struct MOZ_NONHEAP_CLASS X
{
16 void *operator new(size_t x
, int qual
) MOZ_HEAP_ALLOCATOR
{
17 return ::operator new(x
);
21 T
*customAlloc() MOZ_HEAP_ALLOCATOR
{
22 T
*arg
= static_cast<T
*>(malloc(sizeof(T
)));
27 X
*foo
= customAlloc
<X
>(); // expected-error {{variable of type 'X' is not valid on the heap}} expected-note {{value incorrectly allocated on the heap}}
28 X
*foo2
= new (100) X(); // expected-error {{variable of type 'X' is not valid on the heap}} expected-note {{value incorrectly allocated on the heap}}