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

Fix code generation when the if branch has a value and there is no else branch #4949

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

ogoffart
Copy link
Member

Fixes #4942

@ogoffart ogoffart requested a review from tronical March 26, 2024 17:53
@ogoffart
Copy link
Member Author

Currently the C++ test fails:

/tmp/.tmpS3RnNa.cpp: In lambda function:
/tmp/.tmpS3RnNa.cpp:71:46: error: statement has no effect [-Werror=unused-value]
   71 |     return [&]{ [&]() -> void { if (arg_0) { 45; } else { ; }}();return 12; }();
      |                                              ^~
cc1plus: all warnings being treated as errors

I wonder what to do:

  1. ignore this test for c++ with the ignore: cpp comment
  2. Somehow find a way to add -Wno-unused-value to that test only. How?
  3. Add -Wno-unused-value to all C++ tests
  4. workaround the warning somehow in the code.
  5. delete all code that don't do anything in one of the optimization pass. With a warning that the code is useless in the .slint file

What do you think?
5 is the best. But I think short term i'll do the easy 1

@tronical
Copy link
Member

I wonder do you can do the same as in the Rust code generator but instead of appending a semicolon prepending (void) like we used to do in Qt. (void)(someexpr)

But short of that yeah (1) seems the way to go.

@ogoffart ogoffart merged commit 028d075 into master Mar 27, 2024
36 checks passed
@ogoffart ogoffart deleted the olivier/fix-4942 branch March 27, 2024 07:30
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.

Rust error "non-primitive cast" with a weird key-pressed handler
2 participants