macro_misc.c 1007 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // RUN: %clang_cc1 %s -Eonly -verify
  2. // This should not be rejected.
  3. #ifdef defined
  4. #endif
  5. // PR3764
  6. // This should not produce a redefinition warning.
  7. #define FUNC_LIKE(a) (a)
  8. #define FUNC_LIKE(a)(a)
  9. // This either.
  10. #define FUNC_LIKE2(a)\
  11. (a)
  12. #define FUNC_LIKE2(a) (a)
  13. // This should.
  14. #define FUNC_LIKE3(a) ( a) // expected-note {{previous definition is here}}
  15. #define FUNC_LIKE3(a) (a) // expected-warning {{'FUNC_LIKE3' macro redefined}}
  16. // RUN: %clang_cc1 -fms-extensions -DMS_EXT %s -Eonly -verify
  17. #ifndef MS_EXT
  18. // This should under C99.
  19. #define FUNC_LIKE4(a,b) (a+b) // expected-note {{previous definition is here}}
  20. #define FUNC_LIKE4(x,y) (x+y) // expected-warning {{'FUNC_LIKE4' macro redefined}}
  21. #else
  22. // This shouldn't under MS extensions.
  23. #define FUNC_LIKE4(a,b) (a+b)
  24. #define FUNC_LIKE4(x,y) (x+y)
  25. // This should.
  26. #define FUNC_LIKE5(a,b) (a+b) // expected-note {{previous definition is here}}
  27. #define FUNC_LIKE5(x,y) (y+x) // expected-warning {{'FUNC_LIKE5' macro redefined}}
  28. #endif