Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compiler-construction
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
User expired
compiler-construction
Commits
bc1516ce
Commit
bc1516ce
authored
5 years ago
by
Clemens Paumgarten
Browse files
Options
Downloads
Patches
Plain Diff
Fix segfault on array binar op check
parent
5940e8df
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/symbol_table_parse.c
+1
-1
1 addition, 1 deletion
src/symbol_table_parse.c
src/symbol_table_validate.c
+2
-4
2 additions, 4 deletions
src/symbol_table_validate.c
with
3 additions
and
5 deletions
src/symbol_table_parse.c
+
1
−
1
View file @
bc1516ce
...
@@ -160,7 +160,7 @@ int mcc_symbol_table_parse_statement(
...
@@ -160,7 +160,7 @@ int mcc_symbol_table_parse_statement(
}
else
{
}
else
{
return
1
;
return
1
;
}
}
case
MCC_AST_STATEMENT_TYPE_IF
:
;
case
MCC_AST_STATEMENT_TYPE_IF
:
if
(
mcc_symbol_table_validate_expression
(
if
(
mcc_symbol_table_validate_expression
(
statement
->
if_condition
,
symbol_table
,
ec
)
==
0
)
{
statement
->
if_condition
,
symbol_table
,
ec
)
==
0
)
{
if
(
mcc_symbol_table_validate_condition_to_type_bool
(
if
(
mcc_symbol_table_validate_condition_to_type_bool
(
...
...
This diff is collapsed.
Click to expand it.
src/symbol_table_validate.c
+
2
−
4
View file @
bc1516ce
...
@@ -340,7 +340,7 @@ int binary_operator_contains_illegal_array(
...
@@ -340,7 +340,7 @@ int binary_operator_contains_illegal_array(
struct
mcc_symbol_table
*
symbol_table
,
struct
mcc_symbol_table
*
symbol_table
,
struct
mcc_symbol_table_error_collector
*
ec
struct
mcc_symbol_table_error_collector
*
ec
)
{
)
{
if
(
expression
->
identifier
!=
NULL
)
{
if
(
expression
->
type
==
MCC_AST_EXPRESSION_TYPE_IDENTIFIER
&&
expression
->
identifier
!=
NULL
)
{
struct
mcc_symbol
*
s
=
mcc_symbol_table_get_symbol
(
symbol_table
,
expression
->
identifier
->
i_value
);
struct
mcc_symbol
*
s
=
mcc_symbol_table_get_symbol
(
symbol_table
,
expression
->
identifier
->
i_value
);
// this is a binary op with an array without index provided
// this is a binary op with an array without index provided
...
@@ -371,8 +371,7 @@ int mcc_symbol_table_validate_binary_operator(
...
@@ -371,8 +371,7 @@ int mcc_symbol_table_validate_binary_operator(
}
}
int
illegal_array_op_lhs
=
binary_operator_contains_illegal_array
(
expression
->
lhs
,
symbol_table
,
ec
);
int
illegal_array_op_lhs
=
binary_operator_contains_illegal_array
(
expression
->
lhs
,
symbol_table
,
ec
);
int
illegal_array_op_rhs
=
binary_operator_contains_illegal_array
(
expression
->
lhs
,
symbol_table
,
ec
);
int
illegal_array_op_rhs
=
binary_operator_contains_illegal_array
(
expression
->
rhs
,
symbol_table
,
ec
);
if
(
illegal_array_op_lhs
||
illegal_array_op_rhs
)
{
if
(
illegal_array_op_lhs
||
illegal_array_op_rhs
)
{
return
1
;
return
1
;
}
}
...
@@ -437,7 +436,6 @@ int mcc_symbol_table_validate_expression(
...
@@ -437,7 +436,6 @@ int mcc_symbol_table_validate_expression(
assert
(
symbol_table
);
assert
(
symbol_table
);
assert
(
ec
);
assert
(
ec
);
switch
(
expression
->
type
)
{
switch
(
expression
->
type
)
{
case
MCC_AST_EXPRESSION_TYPE_IDENTIFIER
:
case
MCC_AST_EXPRESSION_TYPE_IDENTIFIER
:
return
mcc_symbol_table_validate_identifier
(
expression
->
identifier
,
symbol_table
,
ec
);
return
mcc_symbol_table_validate_identifier
(
expression
->
identifier
,
symbol_table
,
ec
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment