macro_arg_directive.c 801 B

1234567891011121314151617181920212223242526272829303132
  1. // RUN: %clang_cc1 %s -fsyntax-only -verify
  2. #define a(x) enum { x }
  3. a(n =
  4. #undef a
  5. #define a 5
  6. a);
  7. _Static_assert(n == 5, "");
  8. #define M(A)
  9. M(
  10. #pragma pack(pop) // expected-error {{embedding a #pragma directive within macro arguments is not supported}}
  11. )
  12. // header1.h
  13. void fail(const char *);
  14. #define MUNCH(...) \
  15. ({ int result = 0; __VA_ARGS__; if (!result) { fail(#__VA_ARGS__); }; result })
  16. static inline int f(int k) {
  17. return MUNCH( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{returning 'void'}}
  18. if (k < 3)
  19. result = 24;
  20. else if (k > 4)
  21. result = k - 4;
  22. }
  23. #include "macro_arg_directive.h" // expected-error {{embedding a #include directive within macro arguments is not supported}}
  24. int g(int k) {
  25. return f(k) + f(k-1));
  26. }