-
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-base.cc (HIRCompileBase::lvalue_p): Created a function that checks the lvalue. * backend/rust-compile-base.h: Created the Signature for above function * backend/rust-compile-expr.cc (lvalue_p): Moved the function from here to rust-compile-base. (CompileExpr::visit): Made changes to ensure proper readability and checking for wrong assignments. Signed-off-by: Sri Ganesh Thota <[email protected]>
- Loading branch information
1 parent
55a9d8d
commit ba91a60
Showing
4 changed files
with
71 additions
and
1 deletion.
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
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); | ||
} | ||
} |