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
7cfc62ba
Commit
7cfc62ba
authored
Dec 22, 2010
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't crash on index into erroneous map.
From-SVN: r168185
parent
8332d80e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
gcc/go/gofrontend/expressions.cc
+17
-5
gcc/go/gofrontend/gogo.cc
+6
-1
gcc/go/gofrontend/statements.cc
+4
-0
No files found.
gcc/go/gofrontend/expressions.cc
View file @
7cfc62ba
...
...
@@ -9630,7 +9630,8 @@ Map_type*
Map_index_expression
::
get_map_type
()
const
{
Map_type
*
mt
=
this
->
map_
->
type
()
->
deref
()
->
map_type
();
gcc_assert
(
mt
!=
NULL
);
if
(
mt
==
NULL
)
gcc_assert
(
saw_errors
());
return
mt
;
}
...
...
@@ -9649,7 +9650,10 @@ Map_index_expression::do_traverse(Traverse* traverse)
Type
*
Map_index_expression
::
do_type
()
{
Type
*
type
=
this
->
get_map_type
()
->
val_type
();
Map_type
*
mt
=
this
->
get_map_type
();
if
(
mt
==
NULL
)
return
Type
::
make_error_type
();
Type
*
type
=
mt
->
val_type
();
// If this map index is in a tuple assignment, we actually return a
// pointer to the value type. Tuple_map_assignment_statement is
// responsible for handling this correctly. We need to get the type
...
...
@@ -9665,7 +9669,9 @@ void
Map_index_expression
::
do_determine_type
(
const
Type_context
*
)
{
this
->
map_
->
determine_type_no_context
();
Type_context
subcontext
(
this
->
get_map_type
()
->
key_type
(),
false
);
Map_type
*
mt
=
this
->
get_map_type
();
Type
*
key_type
=
mt
==
NULL
?
NULL
:
mt
->
key_type
();
Type_context
subcontext
(
key_type
,
false
);
this
->
index_
->
determine_type
(
&
subcontext
);
}
...
...
@@ -9675,8 +9681,10 @@ void
Map_index_expression
::
do_check_types
(
Gogo
*
)
{
std
::
string
reason
;
if
(
!
Type
::
are_assignable
(
this
->
get_map_type
()
->
key_type
(),
this
->
index_
->
type
(),
&
reason
))
Map_type
*
mt
=
this
->
get_map_type
();
if
(
mt
==
NULL
)
return
;
if
(
!
Type
::
are_assignable
(
mt
->
key_type
(),
this
->
index_
->
type
(),
&
reason
))
{
if
(
reason
.
empty
())
this
->
report_error
(
_
(
"incompatible type for map index"
));
...
...
@@ -9695,6 +9703,8 @@ tree
Map_index_expression
::
do_get_tree
(
Translate_context
*
context
)
{
Map_type
*
type
=
this
->
get_map_type
();
if
(
type
==
NULL
)
return
error_mark_node
;
tree
valptr
=
this
->
get_value_pointer
(
context
,
this
->
is_lvalue_
);
if
(
valptr
==
error_mark_node
)
...
...
@@ -9732,6 +9742,8 @@ Map_index_expression::get_value_pointer(Translate_context* context,
bool
insert
)
{
Map_type
*
type
=
this
->
get_map_type
();
if
(
type
==
NULL
)
return
error_mark_node
;
tree
map_tree
=
this
->
map_
->
get_tree
(
context
);
tree
index_tree
=
this
->
index_
->
get_tree
(
context
);
...
...
gcc/go/gofrontend/gogo.cc
View file @
7cfc62ba
...
...
@@ -3160,7 +3160,12 @@ Type*
Variable
::
type_from_tuple
(
Expression
*
expr
,
bool
report_error
)
const
{
if
(
expr
->
map_index_expression
()
!=
NULL
)
return
expr
->
map_index_expression
()
->
get_map_type
()
->
val_type
();
{
Map_type
*
mt
=
expr
->
map_index_expression
()
->
get_map_type
();
if
(
mt
==
NULL
)
return
Type
::
make_error_type
();
return
mt
->
val_type
();
}
else
if
(
expr
->
receive_expression
()
!=
NULL
)
{
Expression
*
channel
=
expr
->
receive_expression
()
->
channel
();
...
...
gcc/go/gofrontend/statements.cc
View file @
7cfc62ba
...
...
@@ -922,6 +922,8 @@ Tuple_map_assignment_statement::do_lower(Gogo*, Block* enclosing)
return
Statement
::
make_error_statement
(
loc
);
}
Map_type
*
map_type
=
map_index
->
get_map_type
();
if
(
map_type
==
NULL
)
return
Statement
::
make_error_statement
(
loc
);
Block
*
b
=
new
Block
(
enclosing
,
loc
);
...
...
@@ -1066,6 +1068,8 @@ Map_assignment_statement::do_lower(Gogo*, Block* enclosing)
return
Statement
::
make_error_statement
(
loc
);
}
Map_type
*
map_type
=
map_index
->
get_map_type
();
if
(
map_type
==
NULL
)
return
Statement
::
make_error_statement
(
loc
);
Block
*
b
=
new
Block
(
enclosing
,
loc
);
...
...
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