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
6481a43b
Commit
6481a43b
authored
Mar 07, 2011
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle predeclared names used as fields in struct composite literals.
From-SVN: r170754
parent
27062604
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
35 deletions
+25
-35
gcc/go/gofrontend/expressions.cc
+25
-27
gcc/go/gofrontend/expressions.h
+0
-8
No files found.
gcc/go/gofrontend/expressions.cc
View file @
6481a43b
...
...
@@ -936,14 +936,6 @@ Var_expression::do_lower(Gogo* gogo, Named_object* function, int)
return
this
;
}
// Return the name of the variable.
const
std
::
string
&
Var_expression
::
name
()
const
{
return
this
->
variable_
->
name
();
}
// Return the type of a reference to a variable.
Type
*
...
...
@@ -1125,14 +1117,6 @@ Expression::make_sink(source_location location)
// a function seems like it could work, though there might be little
// point to it.
// Return the name of the function.
const
std
::
string
&
Func_expression
::
name
()
const
{
return
this
->
function_
->
name
();
}
// Traversal.
int
...
...
@@ -2359,10 +2343,6 @@ class Const_expression : public Expression
named_object
()
{
return
this
->
constant_
;
}
const
std
::
string
&
name
()
const
{
return
this
->
constant_
->
name
();
}
// Check that the initializer does not refer to the constant itself.
void
check_for_init_loop
();
...
...
@@ -11645,7 +11625,7 @@ class Composite_literal_expression : public Parser_expression
private
:
Expression
*
lower_struct
(
Type
*
);
lower_struct
(
Gogo
*
,
Type
*
);
Expression
*
lower_array
(
Type
*
);
...
...
@@ -11706,7 +11686,7 @@ Composite_literal_expression::do_lower(Gogo* gogo, Named_object* function, int)
if
(
type
->
is_error_type
())
return
Expression
::
make_error
(
this
->
location
());
else
if
(
type
->
struct_type
()
!=
NULL
)
return
this
->
lower_struct
(
type
);
return
this
->
lower_struct
(
gogo
,
type
);
else
if
(
type
->
array_type
()
!=
NULL
)
return
this
->
lower_array
(
type
);
else
if
(
type
->
map_type
()
!=
NULL
)
...
...
@@ -11723,7 +11703,7 @@ Composite_literal_expression::do_lower(Gogo* gogo, Named_object* function, int)
// Lower a struct composite literal.
Expression
*
Composite_literal_expression
::
lower_struct
(
Type
*
type
)
Composite_literal_expression
::
lower_struct
(
Gogo
*
gogo
,
Type
*
type
)
{
source_location
location
=
this
->
location
();
Struct_type
*
st
=
type
->
struct_type
();
...
...
@@ -11751,6 +11731,7 @@ Composite_literal_expression::lower_struct(Type* type)
bool
bad_key
=
false
;
std
::
string
name
;
const
Named_object
*
no
=
NULL
;
switch
(
name_expr
->
classification
())
{
case
EXPRESSION_UNKNOWN_REFERENCE
:
...
...
@@ -11758,7 +11739,7 @@ Composite_literal_expression::lower_struct(Type* type)
break
;
case
EXPRESSION_CONST_REFERENCE
:
n
ame
=
static_cast
<
Const_expression
*>
(
name_expr
)
->
name
();
n
o
=
static_cast
<
Const_expression
*>
(
name_expr
)
->
named_object
();
break
;
case
EXPRESSION_TYPE
:
...
...
@@ -11768,16 +11749,16 @@ Composite_literal_expression::lower_struct(Type* type)
if
(
nt
==
NULL
)
bad_key
=
true
;
else
n
ame
=
nt
->
name
();
n
o
=
nt
->
named_object
();
}
break
;
case
EXPRESSION_VAR_REFERENCE
:
n
ame
=
name_expr
->
var_expression
()
->
name
();
n
o
=
name_expr
->
var_expression
()
->
named_object
();
break
;
case
EXPRESSION_FUNC_REFERENCE
:
n
ame
=
name_expr
->
func_expression
()
->
name
();
n
o
=
name_expr
->
func_expression
()
->
named_object
();
break
;
case
EXPRESSION_UNARY
:
...
...
@@ -11825,6 +11806,23 @@ Composite_literal_expression::lower_struct(Type* type)
return
Expression
::
make_error
(
location
);
}
if
(
no
!=
NULL
)
{
name
=
no
->
name
();
// A predefined name won't be packed. If it starts with a
// lower case letter we need to check for that case, because
// the field name will be packed.
if
(
!
Gogo
::
is_hidden_name
(
name
)
&&
name
[
0
]
>=
'a'
&&
name
[
0
]
<=
'z'
)
{
Named_object
*
gno
=
gogo
->
lookup_global
(
name
.
c_str
());
if
(
gno
==
no
)
name
=
gogo
->
pack_hidden_name
(
name
,
false
);
}
}
unsigned
int
index
;
const
Struct_field
*
sf
=
st
->
find_local_field
(
name
,
&
index
);
if
(
sf
==
NULL
)
...
...
gcc/go/gofrontend/expressions.h
View file @
6481a43b
...
...
@@ -903,10 +903,6 @@ class Var_expression : public Expression
named_object
()
const
{
return
this
->
variable_
;
}
// Return the name of the variable.
const
std
::
string
&
name
()
const
;
protected
:
Expression
*
do_lower
(
Gogo
*
,
Named_object
*
,
int
);
...
...
@@ -1314,10 +1310,6 @@ class Func_expression : public Expression
named_object
()
const
{
return
this
->
function_
;
}
// Return the name of the function.
const
std
::
string
&
name
()
const
;
// Return the closure for this function. This will return NULL if
// the function has no closure, which is the normal case.
Expression
*
...
...
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