expr_liveness.c 712 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* RUN: %clang_cc1 -E %s -DNO_ERRORS -Werror -Wundef
  2. RUN: not %clang_cc1 -E %s
  3. */
  4. #ifdef NO_ERRORS
  5. /* None of these divisions by zero are in live parts of the expression, do not
  6. emit any diagnostics. */
  7. #define MACRO_0 0
  8. #define MACRO_1 1
  9. #if MACRO_0 && 10 / MACRO_0
  10. foo
  11. #endif
  12. #if MACRO_1 || 10 / MACRO_0
  13. bar
  14. #endif
  15. #if 0 ? 124/0 : 42
  16. #endif
  17. // PR2279
  18. #if 0 ? 1/0: 2
  19. #else
  20. #error
  21. #endif
  22. // PR2279
  23. #if 1 ? 2 ? 3 : 4 : 5
  24. #endif
  25. // PR2284
  26. #if 1 ? 0: 1 ? 1/0: 1/0
  27. #endif
  28. #else
  29. /* The 1/0 is live, it should error out. */
  30. #if 0 && 1 ? 4 : 1 / 0
  31. baz
  32. #endif
  33. #endif
  34. // rdar://6505352
  35. // -Wundef should not warn about use of undefined identifier if not live.
  36. #if (!defined(XXX) || XXX > 42)
  37. #endif