mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-12 10:17:31 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
28
build/clang-plugin/tests/TestCustomHeap.cpp
Normal file
28
build/clang-plugin/tests/TestCustomHeap.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class")))
|
||||
#define MOZ_HEAP_ALLOCATOR \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wgcc-compat\"") \
|
||||
__attribute__((annotate("moz_heap_allocator"))) \
|
||||
_Pragma("GCC diagnostic pop")
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <memory>
|
||||
|
||||
struct MOZ_NONHEAP_CLASS X {
|
||||
};
|
||||
|
||||
void *operator new(size_t x, int qual) MOZ_HEAP_ALLOCATOR {
|
||||
return ::operator new(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *customAlloc() MOZ_HEAP_ALLOCATOR {
|
||||
T *arg = static_cast<T*>(malloc(sizeof(T)));
|
||||
return new (arg) T();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void misuseX(T q) {
|
||||
X *foo = customAlloc<X>(); // expected-error {{variable of type 'X' is not valid on the heap}} expected-note {{value incorrectly allocated on the heap}}
|
||||
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}}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue