Skip to content
Snippets Groups Projects
Commit 8b5f23f7 authored by zhaochaoyi's avatar zhaochaoyi
Browse files

Lab2 fix bug:Args

parent 1c00a6a6
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -795,6 +795,8 @@ static void Semantic_Check_Args(Node_t * root) {
head = list;
if(root->lchild != root->rchild) {
cur = cur->rchild;
} else {
cur = cur->lchild;
}
while (type(cur,"Args")) {
Semantic_Check_Exp(cur->lchild);
......@@ -803,7 +805,7 @@ static void Semantic_Check_Args(Node_t * root) {
list = list->tail;
}
if(!type_ops->field_equal(root->inh->u.func.var_list,head)) {
ErrorHandling(9,root->lchild->right->line,",");
ErrorHandling(9,root->lchild->line,root->lchild->text);
}
type_ops->field_delete(head);
}
......
......@@ -230,6 +230,8 @@ static void SymbolStack_push(stack_ele_t * item) {
next->prev = item;
item->prev = first;
symbol_stack->stack_size++;
item->head.type = next->head.type;
}
static void SymbolStack_pop() {
......
/* Test by Zhao Chaoyi */
struct {
int a,b;
}a;
struct type_1 {
float c;
int d;
};
struct type_2 {
float a;
struct type_1 t1;
}t1,t2,t3,t4;
int func_1() {
return 1;
}
int main() {
int a;
if(b > 1) {
non_exists_func(a,t1);
} else {
int a;
float a;
}
return 0;
}
float func_1(int c) {
return 1;
}
float func_2() {
int a;
a = 1.0;
1 = a;
t1 = t3 + t4;
return a;
}
int func_3(int c,int d) {
int d = func_1(0.1);
return d[1];
}
struct type_1 func_4(int d) {
struct type_2 t;
int array[100];
t();
array[1.5];
{
int c = d.a;
c = t.t1.a;
}
}
struct type_2 {
float a;
int d = 0;
struct non_exist tt;
};
/* correct Test */
int a[100];
int printf(int n);
int display(struct {int a,b,c;} n);
int main() {
int a = 0,sum = 0;
while (a < 1000) {
sum = sum + a;
a = a + 1;
}
if(sum > a * 1000) {
printf(sum);
}
return sum;
}
int func() {
struct t1 {
int x,y,z;
} point1,point2;
point1.x = point2.x = 1;
point1.y = point2.y = 2;
point1.z = point3.z = 3;
return display(point1);
}
int print(int n) {
return n;
}
int display(struct {int a,b,c;} n) {
int sum = 0;
sum = n.a + n.b + n.c;
if(sum > 10) {
int mid = sum * 10;
return mid/5;
} else if(sum < 0) {
return - 1;
} else {
int all = sum * 2;
if(all) {
return printf(all);
} else {
return -all;
}
}
}
\ No newline at end of file
......@@ -20,7 +20,8 @@ int func_1() {
int main() {
int a;
if(b > 1) {
b;
if(1) {
non_exists_func(a,t1);
} else {
int a;
......@@ -30,7 +31,7 @@ int main() {
}
float func_1(int c) {
return 0.1;
return 1;
}
float func_2() {
......@@ -42,7 +43,7 @@ float func_2() {
}
int func_3(int c,int d) {
int d = func_1(0.1);
int e = func_1(0.1);
return d[1];
}
......@@ -52,8 +53,8 @@ struct type_1 func_4(int d) {
t();
array[1.5];
{
int c = d.a;
c = t.t1.a;
int c = d.a;
t.t1.a;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment