release-workaround.m 541 B

12345678910111213141516171819202122232425262728293031323334
  1. // TEST_CONFIG ARCH=x86_64 MEM=mrc
  2. // TEST_CFLAGS -framework Foundation
  3. // rdar://20206767
  4. #include <Foundation/Foundation.h>
  5. #include "test.h"
  6. @interface Test : NSObject @end
  7. @implementation Test
  8. @end
  9. int main()
  10. {
  11. id buf[1];
  12. buf[0] = [Test class];
  13. id obj = (id)buf;
  14. [obj retain];
  15. [obj retain];
  16. uintptr_t rax;
  17. [obj release];
  18. asm("mov %%rax, %0" : "=r" (rax));
  19. testassert(rax == 0);
  20. objc_release(obj);
  21. asm("mov %%rax, %0" : "=r" (rax));
  22. testassert(rax == 0);
  23. succeed(__FILE__);
  24. }