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
93d83339
Commit
93d83339
authored
Sep 10, 2011
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix using package name as composite literal struct key.
From-SVN: r178747
parent
049d2893
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
3 deletions
+36
-3
gcc/go/gofrontend/expressions.cc
+0
-1
gcc/go/gofrontend/parse.cc
+36
-2
No files found.
gcc/go/gofrontend/expressions.cc
View file @
93d83339
...
@@ -1436,7 +1436,6 @@ Unknown_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
...
@@ -1436,7 +1436,6 @@ Unknown_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
Expression
*
Expression
*
Expression
::
make_unknown_reference
(
Named_object
*
no
,
source_location
location
)
Expression
::
make_unknown_reference
(
Named_object
*
no
,
source_location
location
)
{
{
go_assert
(
no
->
resolve
()
->
is_unknown
());
return
new
Unknown_expression
(
no
,
location
);
return
new
Unknown_expression
(
no
,
location
);
}
}
...
...
gcc/go/gofrontend/parse.cc
View file @
93d83339
...
@@ -2445,7 +2445,9 @@ Parse::enclosing_var_reference(Named_object* in_function, Named_object* var,
...
@@ -2445,7 +2445,9 @@ Parse::enclosing_var_reference(Named_object* in_function, Named_object* var,
// LiteralValue = "{" [ ElementList [ "," ] ] "}" .
// LiteralValue = "{" [ ElementList [ "," ] ] "}" .
// ElementList = Element { "," Element } .
// ElementList = Element { "," Element } .
// Element = [ Key ":" ] Value .
// Element = [ Key ":" ] Value .
// Key = Expression .
// Key = FieldName | ElementIndex .
// FieldName = identifier .
// ElementIndex = Expression .
// Value = Expression | LiteralValue .
// Value = Expression | LiteralValue .
// We have already seen the type if there is one, and we are now
// We have already seen the type if there is one, and we are now
...
@@ -2478,7 +2480,33 @@ Parse::composite_lit(Type* type, int depth, source_location location)
...
@@ -2478,7 +2480,33 @@ Parse::composite_lit(Type* type, int depth, source_location location)
const
Token
*
token
=
this
->
peek_token
();
const
Token
*
token
=
this
->
peek_token
();
if
(
!
token
->
is_op
(
OPERATOR_LCURLY
))
if
(
token
->
is_identifier
())
{
std
::
string
identifier
=
token
->
identifier
();
bool
is_exported
=
token
->
is_identifier_exported
();
source_location
location
=
token
->
location
();
if
(
this
->
advance_token
()
->
is_op
(
OPERATOR_COLON
))
{
// This may be a field name. We don't know for sure--it
// could also be an expression for an array index. We
// don't want to parse it as an expression because may
// trigger various errors, e.g., if this identifier
// happens to be the name of a package.
Gogo
*
gogo
=
this
->
gogo_
;
val
=
this
->
id_to_expression
(
gogo
->
pack_hidden_name
(
identifier
,
is_exported
),
location
);
}
else
{
this
->
unget_token
(
Token
::
make_identifier_token
(
identifier
,
is_exported
,
location
));
val
=
this
->
expression
(
PRECEDENCE_NORMAL
,
false
,
true
,
NULL
);
}
}
else
if
(
!
token
->
is_op
(
OPERATOR_LCURLY
))
val
=
this
->
expression
(
PRECEDENCE_NORMAL
,
false
,
true
,
NULL
);
val
=
this
->
expression
(
PRECEDENCE_NORMAL
,
false
,
true
,
NULL
);
else
else
{
{
...
@@ -2922,6 +2950,12 @@ Parse::id_to_expression(const std::string& name, source_location location)
...
@@ -2922,6 +2950,12 @@ Parse::id_to_expression(const std::string& name, source_location location)
return
Expression
::
make_func_reference
(
named_object
,
NULL
,
location
);
return
Expression
::
make_func_reference
(
named_object
,
NULL
,
location
);
case
Named_object
:
:
NAMED_OBJECT_UNKNOWN
:
case
Named_object
:
:
NAMED_OBJECT_UNKNOWN
:
return
Expression
::
make_unknown_reference
(
named_object
,
location
);
return
Expression
::
make_unknown_reference
(
named_object
,
location
);
case
Named_object
:
:
NAMED_OBJECT_PACKAGE
:
case
Named_object
:
:
NAMED_OBJECT_TYPE
:
case
Named_object
:
:
NAMED_OBJECT_TYPE_DECLARATION
:
// These cases can arise for a field name in a composite
// literal.
return
Expression
::
make_unknown_reference
(
named_object
,
location
);
default
:
default
:
error_at
(
this
->
location
(),
"unexpected type of identifier"
);
error_at
(
this
->
location
(),
"unexpected type of identifier"
);
return
Expression
::
make_error
(
location
);
return
Expression
::
make_error
(
location
);
...
...
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