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

test: update to test what is intented and clarify with comments #587

Merged
merged 1 commit into from
Aug 14, 2023

Conversation

JohelEGP
Copy link
Contributor

As pointed out at db63152#r124283230 and 6ce2643#r124372924,
those recent commits did or could change what the test was meant to test.
This PR realigns the test cases with their original intent,
and clarifies with comments the possible implementations it avoids.

JohelEGP referenced this pull request Aug 13, 2023
…unnamed parameters, closes #560

Emit `[[maybe_unused]]` on a `that` parameter if the class is empty.
Add -Wunused-parameter to my GCC and Clang regression tests.
Add `_` unnamed parameter support, and use ordinals instead of line/col numbers to keep the generated names stable.

As an example from one of the updated regression tests that had a helper function to just accept (but not use) five generic parameters, that function is now just: `call: (_, _, _, _, _) = { }`
main: (args) = {
x: quantity = (1729);
_ = x + x; // Not `(void) x + x`; would attempt to add a `void` to `x`.
_ = args; // Not `void(args)`; would attempt to declare `args` with `void` type.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scary syntax can be used to smuggle declarations:
https://cpp2.godbolt.org/z/EsGKsThz3

main: () = i32(x);
auto main() -> int { cpp2::i32(x);  }
main.cpp2:1:32: warning: unused variable 'x' [-Wunused-variable]
    1 | auto main() -> int { cpp2::i32(x);  }
      |                                ^
1 warning generated.
Program returned: 0

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delightful! FWIW Wparentheses would flag that.

@hsutter
Copy link
Owner

hsutter commented Aug 14, 2023

Thanks! I did notice that the test was losing some of its intent, I appreciate this update.

@hsutter hsutter merged commit bf29741 into hsutter:main Aug 14, 2023
@JohelEGP JohelEGP deleted the discard_precedence branch August 14, 2023 01:07
zaucy pushed a commit to zaucy/cppfront that referenced this pull request Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants