-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gccrs: feat: Made changes to ensure no wrong assignments are done.
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.
- Loading branch information
1 parent
55a9d8d
commit 41640eb
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
extern "C" { | ||
fn printf(s: *const i8, ...); | ||
} | ||
|
||
pub fn main() { | ||
unsafe { | ||
let mut x = 42; | ||
x + 1= 2; // { dg-error "invalid left-hand side of assignment" } | ||
let format = "Result: %d\n\0" as *const str as *const i8; | ||
printf(format, x); | ||
} | ||
} |