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
cd96b4e2
Commit
cd96b4e2
authored
Dec 14, 2010
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct handling of undefined name as key in map composite literal.
From-SVN: r167810
parent
7ed66e66
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
+22
-5
gcc/go/gofrontend/expressions.cc
+16
-5
gcc/go/gofrontend/expressions.h
+6
-0
No files found.
gcc/go/gofrontend/expressions.cc
View file @
cd96b4e2
...
...
@@ -11162,7 +11162,7 @@ class Composite_literal_expression : public Parser_expression
make_array
(
Type
*
,
Expression_list
*
);
Expression
*
lower_map
(
Type
*
);
lower_map
(
Gogo
*
,
Named_object
*
,
Type
*
);
// The type of the composite literal.
Type
*
type_
;
...
...
@@ -11191,7 +11191,7 @@ Composite_literal_expression::do_traverse(Traverse* traverse)
// the type.
Expression
*
Composite_literal_expression
::
do_lower
(
Gogo
*
,
Named_object
*
,
int
)
Composite_literal_expression
::
do_lower
(
Gogo
*
gogo
,
Named_object
*
function
,
int
)
{
Type
*
type
=
this
->
type_
;
...
...
@@ -11218,7 +11218,7 @@ Composite_literal_expression::do_lower(Gogo*, Named_object*, int)
else
if
(
type
->
array_type
()
!=
NULL
)
return
this
->
lower_array
(
type
);
else
if
(
type
->
map_type
()
!=
NULL
)
return
this
->
lower_map
(
type
);
return
this
->
lower_map
(
gogo
,
function
,
type
);
else
{
error_at
(
this
->
location
(),
...
...
@@ -11477,7 +11477,8 @@ Composite_literal_expression::make_array(Type* type, Expression_list* vals)
// Lower a map composite literal.
Expression
*
Composite_literal_expression
::
lower_map
(
Type
*
type
)
Composite_literal_expression
::
lower_map
(
Gogo
*
gogo
,
Named_object
*
function
,
Type
*
type
)
{
source_location
location
=
this
->
location
();
if
(
this
->
vals_
!=
NULL
)
...
...
@@ -11488,7 +11489,7 @@ Composite_literal_expression::lower_map(Type* type)
return
Expression
::
make_error
(
location
);
}
for
(
Expression_list
::
const_
iterator
p
=
this
->
vals_
->
begin
();
for
(
Expression_list
::
iterator
p
=
this
->
vals_
->
begin
();
p
!=
this
->
vals_
->
end
();
p
+=
2
)
{
...
...
@@ -11499,6 +11500,16 @@ Composite_literal_expression::lower_map(Type* type)
"map composite literal must have keys for every value"
);
return
Expression
::
make_error
(
location
);
}
// Make sure we have lowered the key; it may not have been
// lowered in order to handle keys for struct composite
// literals. Lower it now to get the right error message.
if
((
*
p
)
->
unknown_expression
()
!=
NULL
)
{
(
*
p
)
->
unknown_expression
()
->
clear_is_composite_literal_key
();
gogo
->
lower_expression
(
function
,
&*
p
);
gcc_assert
((
*
p
)
->
is_error_expression
());
return
Expression
::
make_error
(
location
);
}
}
}
...
...
gcc/go/gofrontend/expressions.h
View file @
cd96b4e2
...
...
@@ -1384,6 +1384,12 @@ class Unknown_expression : public Parser_expression
set_is_composite_literal_key
()
{
this
->
is_composite_literal_key_
=
true
;
}
// Note that this expression should no longer be treated as a
// composite literal key.
void
clear_is_composite_literal_key
()
{
this
->
is_composite_literal_key_
=
false
;
}
protected
:
Expression
*
do_lower
(
Gogo
*
,
Named_object
*
,
int
);
...
...
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