Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement variadic macros #6

Closed
mycoboco opened this issue Nov 6, 2014 · 4 comments
Closed

implement variadic macros #6

mycoboco opened this issue Nov 6, 2014 · 4 comments
Assignees
Milestone

Comments

@mycoboco
Copy link
Owner

mycoboco commented Nov 6, 2014

This enables to test sea-canary against redis code.

@mycoboco mycoboco self-assigned this Nov 20, 2014
@mycoboco mycoboco removed their assignment Mar 15, 2016
@mycoboco mycoboco changed the title implement varargs implement variadic macros Aug 22, 2017
@mycoboco
Copy link
Owner Author

Supporting variadic macros itself is easy, but due to the constraint from 6.10.3:

The identifier __VA_ARGS__ shall occur only in the replacement-list of a function-like macro that uses the ellipsis notation in the parameters.

issuing diagnostics against every appearance of __VA_ARGS__ is cumbersome.

@mycoboco mycoboco self-assigned this Aug 22, 2017
@mycoboco mycoboco added this to the 0.0.1 milestone Aug 22, 2017
@mycoboco
Copy link
Owner Author

mycoboco commented Aug 23, 2017

Places to handle __VA_ARGS__:

  • #define __VA_ARGS__
  • #ifdef __VA_ARGS__
  • #ifndef __VA_ARGS__
  • #undef __VA_ARGS__
  • #error ... __VA_ARGS__
  • #pragma __VA_ARGS__

@mycoboco
Copy link
Owner Author

Diagnostics for unrecognized #pragmas seem to be enough.
__VA_ARGS__ needs to be detected only when it can appear in supported #pragmas.

@mycoboco
Copy link
Owner Author

mycoboco commented Aug 28, 2017

To compare to gcc and clang:
gcc 5.4.0

  • diagnoses uses of __VA_ARGS__
    • on non-directives,
    • in extra tokens,
    • on unrecognized #pragma and
    • on #error,
  • and does not
    • in branch tests ignored by conditional inclusion.

clang 8.1.0

  • issues uses of __VA_ARGS__
    • on non-directives,
    • in extra tokens and
    • on unrecognized #pragma and
    • in branch tests ignored by conditional inclusion.
  • and does not
    • on #error

beluga

  • issues uses of __VA_ARGS__
    • on #error,
  • and does not
    • on non-directives,
    • in extra tokens,
    • on unrecognized #pragma and
    • in branch tests ignored by conditional inclusion.

Not issuing diagnostics for __VA_ARGS__ can be excused when other diagnostics are in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant