Skip to content

[5.9] [Macros] Diagnose top-level expansion of undefined freestanding macro #65440

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

Merged
merged 1 commit into from
Apr 27, 2023

Conversation

rxwei
Copy link
Contributor

@rxwei rxwei commented Apr 26, 2023

Cherry-pick of #65429


  • Explanation: Expanding an undefined macro succeeds silently and causes its arguments to not be type-checked. This is a bad state where incorrect freestanding macro expansion code would slip by and compile to nothing.
  • Scope of Issue: Macro resolution where there is a shortcut only meant to apply to custom attributes.
  • Risk: No risk to custom attributes, or to defined freestanding macro expanisons. All undefined freestanding macro expansions now go through the constraint system, which is an existing code path that those parsed as MacroExpansionExpr already go through, so the risk should be minimal.
  • Testing: Added additional diagnostics tests for top-level freestanding macro expansions in library mode.

rdar://108280416

@rxwei rxwei requested a review from a team as a code owner April 26, 2023 18:31
@rxwei
Copy link
Contributor Author

rxwei commented Apr 26, 2023

@swift-ci please test

@rxwei
Copy link
Contributor Author

rxwei commented Apr 26, 2023

@swift-ci please test macos

@rxwei rxwei merged commit d4327cc into swiftlang:release/5.9 Apr 27, 2023
@rxwei rxwei deleted the 108280416-5.9 branch April 27, 2023 03:18
@AnthonyLatsis AnthonyLatsis added the 🍒 release cherry pick Flag: Release branch cherry picks label May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants