authorgravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2017-09-20 22:14:39-07:00
committergravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2017-09-20 22:14:39-07:00
log33784871ec8d809d513193f5e24865059231b1f3
tree7e89e284d7b5599bf6505665785a0816ad6f8eca
parentf7cb77a02c2e32e9522b247e4653f1c03a677266

assign


2 files changed, 17 insertions(+), 3 deletions(-)

src/parsec.cpp+5-3
......@@ -995,9 +995,11 @@ static AstNode *trans_binary_operator(Context *c, bool result_used, AstNode *blo
995995 // TODO: int vs bool
996996 return trans_create_bin_op(c, block, stmt->getLHS(), BinOpTypeBoolOr, stmt->getRHS());
997997 case BO_Assign:
998 (void)result_used;
999 emit_warning(c, stmt->getLocStart(), "TODO handle more C binary operators: BO_Assign");
1000 return nullptr;
998 if (result_used) {
999 emit_warning(c, stmt->getLocStart(), "TODO handle more C binary operators: BO_Assign with result_used");
1000 return nullptr;
1001 }
1002 return trans_create_bin_op(c, block, stmt->getLHS(), BinOpTypeAssign, stmt->getRHS());
10011003 case BO_MulAssign:
10021004 emit_warning(c, stmt->getLocStart(), "TODO handle more C binary operators: BO_MulAssign");
10031005 return nullptr;
test/parsec.zig+12
......@@ -415,6 +415,18 @@ pub fn addCases(cases: &tests.ParseCContext) {
415415 \\}
416416 );
417417
418 cases.add("assign",
419 \\int max(int a) {
420 \\ int tmp;
421 \\ tmp = a;
422 \\}
423 ,
424 \\export fn max(a: c_int) -> c_int {
425 \\ var tmp: c_int;
426 \\ tmp = a;
427 \\}
428 );
429
418430 cases.add("shift right assign with a fixed size type",
419431 \\#include <stdint.h>
420432 \\int log2(uint32_t a) {