gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

gccrs: feat: Made changes to ensure no wrong assignments are done.

Open sriganeshres opened this issue 1 year ago • 5 comments

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (lvalue_p): Created a function that checks the lvalue. (CompileExpr::visit): Modified the function to check the lvalue using the above mentioned function and also checks the type of lvalue expression.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3287.rs: New test for testing wrong assignments.

Fixes #3287

  • [x] GCC development requires copyright assignment or the Developer's Certificate of Origin sign-off, see https://gcc.gnu.org/contribute.html or https://gcc.gnu.org/dco.html
  • [x] Read contributing guidlines
  • [x] make check-rust passes locally
  • [x] Run clang-format
  • [x] Added any relevant test cases to gcc/testsuite/rust/

sriganeshres avatar Dec 11 '24 17:12 sriganeshres

There are changes required here i think we can get away wit this check but not totally convinced yet

Also it will need to be applied to the other assignments such as:

x +=1 etc

Can you give me more information about the case we are missing as x+= 1 is valid as long as x is mutable in rust.

sriganeshres avatar Dec 14 '24 16:12 sriganeshres

There are changes required here i think we can get away wit this check but not totally convinced yet Also it will need to be applied to the other assignments such as: x +=1 etc

Can you give me more information about the case we are missing as x+= 1 is valid as long as x is mutable in rust.

You have to adjust the visitor for CompoundAssignmentExpr as well as the visitor for AssignmentExpr

powerboat9 avatar Jan 01 '25 00:01 powerboat9

Would probably be good to make lvalue_p operate on HIR nodes instead of trees

powerboat9 avatar Jan 01 '25 19:01 powerboat9

I guess they failing now because of newer tests. If this this merged with upstream there will not be as issue-3147.rs file is added after this changes.

sriganeshres avatar Mar 22 '25 09:03 sriganeshres

You need to rebase you code and investigate why you have failing tests.

philberty avatar Mar 24 '25 14:03 philberty