Skip to content

Commit 3d4108e

Browse files
committed
fixed some compilation warnings for C++
1 parent 2bbb36b commit 3d4108e

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ AstMergeStrings(AST *left, AST *right)
565565
}
566566
newLen += AstStringLen(right);
567567
}
568-
char *newBuf = malloc(newLen);
568+
char *newBuf = (char *)malloc(newLen);
569569
char *p = newBuf;
570570
if (left) {
571571
p = CopyString(p, left);

backends/asm/optimize_ir.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ ReplaceOpcode(IR *ir, IROpcode op)
107107
// NULL if multiple jumps (or none at all)
108108
static IR *UniqJumpForLabel(IR *lbl) {
109109
if (lbl->opc != OPC_LABEL) ERROR(NULL,"internal error, UniqJumpForLabel called on wrong opc %d",lbl->opc);
110-
struct ir_lbljumps *list = lbl->aux;
110+
struct ir_lbljumps *list = (struct ir_lbljumps *)lbl->aux;
111111
if (list && !list->next) return list->jump;
112112
else return NULL;
113113
}
114114

115115
static void AppendLblJump(IR *lbl,IR *jmp) {
116116
if (lbl->opc != OPC_LABEL) ERROR(NULL,"internal error, AppendLblJump called on wrong opc %d",lbl->opc);
117-
struct ir_lbljumps *entry = malloc(sizeof(struct ir_lbljumps));
118-
entry->next = lbl->aux;
117+
struct ir_lbljumps *entry = (struct ir_lbljumps *)malloc(sizeof(struct ir_lbljumps));
118+
entry->next = (struct ir_lbljumps *)lbl->aux;
119119
entry->jump = jmp;
120120
lbl->aux = entry;
121121
}
@@ -1168,7 +1168,7 @@ doIsDeadAfter(IR *instr, Operand *op, int level, IR **stack)
11681168
// Not sure what this check is for? But moved it out of the check loop
11691169
continue;
11701170
}
1171-
for (struct ir_lbljumps *list = ir->aux;list;list=list->next) {
1171+
for (struct ir_lbljumps *list = (struct ir_lbljumps *)ir->aux;list;list=list->next) {
11721172
IR *comefrom = list->jump;
11731173
if (comefrom->addr < instr->addr) {
11741174
// go back and see if there are any references before the
@@ -1474,7 +1474,7 @@ SafeToReplaceForward(IR *first_ir, Operand *orig, Operand *replace, IRCond sette
14741474
// however, in the special case that the register is never
14751475
// actually used again then it's safe
14761476
bool jumpers_before = false;
1477-
for(struct ir_lbljumps *list = ir->aux;list;list=list->next) {
1477+
for(struct ir_lbljumps *list = (struct ir_lbljumps *)ir->aux;list;list=list->next) {
14781478
if (list->jump->addr < first_ir->addr) {
14791479
jumpers_before = true;
14801480
}

backends/asm/outasm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ static Operand *DupOperandWithPrefix(Operand *oldOperand, const char *prefix) {
564564
oldOperand = (Operand *)oldOperand->name;
565565
needSubreg = true;
566566
}
567-
newName = calloc(1, strlen(prefix)+strlen(oldOperand->name)+1);
567+
newName = (char *)calloc(1, strlen(prefix)+strlen(oldOperand->name)+1);
568568
strcpy(newName, prefix);
569569
strcat(newName, oldOperand->name);
570570
if (needSubreg) {
@@ -673,7 +673,7 @@ void ReplaceIRWithInline(IRList *irl, IR *origir, Function *func)
673673
// do nothing
674674
} else {
675675
ir->dst = NewCodeLabel();
676-
for (struct ir_lbljumps *list=ir->aux;list;list=list->next) {
676+
for (struct ir_lbljumps *list=(struct ir_lbljumps *)ir->aux;list;list=list->next) {
677677
ReplaceJumpTarget(list->jump, ir->dst);
678678
}
679679
// we used to print an error when there were no jumps, but in fact it is legal

frontends/basic/basiclang.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ doBasicTransform(AST **astptr, bool transformFuncall)
936936
AST *arg = ast->right->left;
937937
if (arg && ast->right->right == NULL && IsConstExpr(arg)) {
938938
int n = EvalConstExpr(arg);
939-
char *s = malloc(2);
939+
char *s = (char *)malloc(2);
940940
s[0] = n;
941941
s[1] = 0;
942942
*ast = *AstStringPtr(s);

0 commit comments

Comments
 (0)