Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
7a2d845d
Commit
7a2d845d
authored
Dec 16, 2010
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't crash on invalid tuple assignment.
From-SVN: r167892
parent
faff9b04
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
18 deletions
+24
-18
gcc/go/gofrontend/expressions.cc
+12
-18
gcc/go/gofrontend/statements.cc
+12
-0
No files found.
gcc/go/gofrontend/expressions.cc
View file @
7a2d845d
...
@@ -8655,6 +8655,9 @@ Call_result_expression::do_traverse(Traverse* traverse)
...
@@ -8655,6 +8655,9 @@ Call_result_expression::do_traverse(Traverse* traverse)
Type
*
Type
*
Call_result_expression
::
do_type
()
Call_result_expression
::
do_type
()
{
{
if
(
this
->
classification
()
==
EXPRESSION_ERROR
)
return
Type
::
make_error_type
();
// THIS->CALL_ can be replaced with a temporary reference due to
// THIS->CALL_ can be replaced with a temporary reference due to
// Call_expression::do_must_eval_in_order when there is an error.
// Call_expression::do_must_eval_in_order when there is an error.
Call_expression
*
ce
=
this
->
call_
->
call_expression
();
Call_expression
*
ce
=
this
->
call_
->
call_expression
();
...
@@ -8668,34 +8671,25 @@ Call_result_expression::do_type()
...
@@ -8668,34 +8671,25 @@ Call_result_expression::do_type()
for
(
unsigned
int
i
=
0
;
i
<
this
->
index_
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
this
->
index_
;
++
i
)
{
{
if
(
pr
==
results
->
end
())
if
(
pr
==
results
->
end
())
return
Type
::
make_error_type
()
;
break
;
++
pr
;
++
pr
;
}
}
if
(
pr
==
results
->
end
())
if
(
pr
==
results
->
end
())
return
Type
::
make_error_type
();
{
this
->
report_error
(
_
(
"number of results does not match "
"number of values"
));
return
Type
::
make_error_type
();
}
return
pr
->
type
();
return
pr
->
type
();
}
}
// Check the type.
This is where we give an error if we're trying to
// Check the type.
Just make sure that we trigger the warning in
//
extract too many values from a call
.
//
do_type
.
void
void
Call_result_expression
::
do_check_types
(
Gogo
*
)
Call_result_expression
::
do_check_types
(
Gogo
*
)
{
{
bool
ok
=
true
;
this
->
type
();
Call_expression
*
ce
=
this
->
call_
->
call_expression
();
if
(
ce
!=
NULL
)
ok
=
this
->
index_
<
ce
->
result_count
();
else
{
// This can happen when the call returns a single value but we
// are asking for the second result.
if
(
this
->
call_
->
is_error_expression
())
return
;
ok
=
false
;
}
if
(
!
ok
)
this
->
report_error
(
_
(
"number of results does not match number of values"
));
}
}
// Determine the type. We have nothing to do here, but the 0 result
// Determine the type. We have nothing to do here, but the 0 result
...
...
gcc/go/gofrontend/statements.cc
View file @
7a2d845d
...
@@ -782,6 +782,12 @@ Tuple_assignment_statement::do_lower(Gogo*, Block* enclosing)
...
@@ -782,6 +782,12 @@ Tuple_assignment_statement::do_lower(Gogo*, Block* enclosing)
{
{
gcc_assert
(
prhs
!=
this
->
rhs_
->
end
());
gcc_assert
(
prhs
!=
this
->
rhs_
->
end
());
if
((
*
plhs
)
->
is_error_expression
()
||
(
*
plhs
)
->
type
()
->
is_error_type
()
||
(
*
prhs
)
->
is_error_expression
()
||
(
*
prhs
)
->
type
()
->
is_error_type
())
continue
;
if
((
*
plhs
)
->
is_sink_expression
())
if
((
*
plhs
)
->
is_sink_expression
())
{
{
b
->
add_statement
(
Statement
::
make_statement
(
*
prhs
));
b
->
add_statement
(
Statement
::
make_statement
(
*
prhs
));
...
@@ -802,6 +808,12 @@ Tuple_assignment_statement::do_lower(Gogo*, Block* enclosing)
...
@@ -802,6 +808,12 @@ Tuple_assignment_statement::do_lower(Gogo*, Block* enclosing)
plhs
!=
this
->
lhs_
->
end
();
plhs
!=
this
->
lhs_
->
end
();
++
plhs
,
++
prhs
)
++
plhs
,
++
prhs
)
{
{
if
((
*
plhs
)
->
is_error_expression
()
||
(
*
plhs
)
->
type
()
->
is_error_type
()
||
(
*
prhs
)
->
is_error_expression
()
||
(
*
prhs
)
->
type
()
->
is_error_type
())
continue
;
if
((
*
plhs
)
->
is_sink_expression
())
if
((
*
plhs
)
->
is_sink_expression
())
continue
;
continue
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment