typeof-safe.c 809 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #define __safe __attribute__((safe))
  2. static void test_safe(void)
  3. {
  4. int obj;
  5. int __safe *ptr;
  6. int __safe *ptr2 = ptr;
  7. typeof(ptr) ptr3 = ptr;
  8. typeof(*ptr) var2 = obj;
  9. int __safe var3 = obj;
  10. int *ptr4 = &obj;
  11. int *ptr5 = ptr; // KO
  12. typeof(*ptr) sobj;
  13. typeof(&sobj) ptr6 = &obj;
  14. typeof(&sobj) ptr7 = ptr; // KO
  15. obj = obj;
  16. ptr = ptr;
  17. obj = *ptr;
  18. ptr = (int __safe *) &obj;
  19. }
  20. /*
  21. * check-name: typeof-safe
  22. *
  23. * check-error-start
  24. typeof-safe.c:13:21: warning: incorrect type in initializer (different modifiers)
  25. typeof-safe.c:13:21: expected int *ptr5
  26. typeof-safe.c:13:21: got int [safe] *ptr
  27. typeof-safe.c:17:30: warning: incorrect type in initializer (different modifiers)
  28. typeof-safe.c:17:30: expected int *ptr7
  29. typeof-safe.c:17:30: got int [safe] *ptr
  30. * check-error-end
  31. */