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
16f72d88
Commit
16f72d88
authored
Dec 19, 2014
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compiler: More cases that need a temporary for interface conversion.
From-SVN: r218952
parent
6b0e0695
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
22 deletions
+74
-22
gcc/go/gofrontend/expressions.cc
+45
-19
gcc/go/gofrontend/statements.cc
+26
-3
gcc/go/gofrontend/statements.h
+3
-0
No files found.
gcc/go/gofrontend/expressions.cc
View file @
16f72d88
...
@@ -5142,6 +5142,9 @@ Expression*
...
@@ -5142,6 +5142,9 @@ Expression*
Binary_expression
::
do_flatten
(
Gogo
*
gogo
,
Named_object
*
,
Binary_expression
::
do_flatten
(
Gogo
*
gogo
,
Named_object
*
,
Statement_inserter
*
inserter
)
Statement_inserter
*
inserter
)
{
{
if
(
this
->
classification
()
==
EXPRESSION_ERROR
)
return
this
;
Location
loc
=
this
->
location
();
Location
loc
=
this
->
location
();
Temporary_statement
*
temp
;
Temporary_statement
*
temp
;
if
(
this
->
left_
->
type
()
->
is_string_type
()
if
(
this
->
left_
->
type
()
->
is_string_type
()
...
@@ -6877,30 +6880,53 @@ Expression*
...
@@ -6877,30 +6880,53 @@ Expression*
Builtin_call_expression
::
do_flatten
(
Gogo
*
,
Named_object
*
,
Builtin_call_expression
::
do_flatten
(
Gogo
*
,
Named_object
*
,
Statement_inserter
*
inserter
)
Statement_inserter
*
inserter
)
{
{
if
(
this
->
code_
==
BUILTIN_APPEND
Location
loc
=
this
->
location
();
||
this
->
code_
==
BUILTIN_COPY
)
switch
(
this
->
code_
)
{
{
Location
loc
=
this
->
location
();
default
:
Type
*
at
=
this
->
args
()
->
front
()
->
type
();
break
;
case
BUILTIN_APPEND
:
case
BUILTIN_COPY
:
{
Type
*
at
=
this
->
args
()
->
front
()
->
type
();
for
(
Expression_list
::
iterator
pa
=
this
->
args
()
->
begin
();
pa
!=
this
->
args
()
->
end
();
++
pa
)
{
if
((
*
pa
)
->
is_nil_expression
())
{
Expression
*
nil
=
Expression
::
make_nil
(
loc
);
Expression
*
zero
=
Expression
::
make_integer_ul
(
0
,
NULL
,
loc
);
*
pa
=
Expression
::
make_slice_value
(
at
,
nil
,
zero
,
zero
,
loc
);
}
if
(
!
(
*
pa
)
->
is_variable
())
{
Temporary_statement
*
temp
=
Statement
::
make_temporary
(
NULL
,
*
pa
,
loc
);
inserter
->
insert
(
temp
);
*
pa
=
Expression
::
make_temporary_reference
(
temp
,
loc
);
}
}
}
break
;
case
BUILTIN_PANIC
:
for
(
Expression_list
::
iterator
pa
=
this
->
args
()
->
begin
();
for
(
Expression_list
::
iterator
pa
=
this
->
args
()
->
begin
();
pa
!=
this
->
args
()
->
end
();
pa
!=
this
->
args
()
->
end
();
++
pa
)
++
pa
)
{
{
if
((
*
pa
)
->
is_nil_expression
()
)
if
(
!
(
*
pa
)
->
is_variable
()
&&
(
*
pa
)
->
type
()
->
interface_type
()
!=
NULL
)
{
{
Expression
*
nil
=
Expression
::
make_nil
(
loc
);
Temporary_statement
*
temp
=
Expression
*
zero
=
Expression
::
make_integer_ul
(
0
,
NULL
,
loc
);
Statement
::
make_temporary
(
NULL
,
*
pa
,
loc
);
*
pa
=
Expression
::
make_slice_value
(
at
,
nil
,
zero
,
zero
,
loc
);
inserter
->
insert
(
temp
);
*
pa
=
Expression
::
make_temporary_reference
(
temp
,
loc
);
}
}
if
(
!
(
*
pa
)
->
is_variable
())
}
{
Temporary_statement
*
temp
=
Statement
::
make_temporary
(
NULL
,
*
pa
,
loc
);
inserter
->
insert
(
temp
);
*
pa
=
Expression
::
make_temporary_reference
(
temp
,
loc
);
}
}
}
}
return
this
;
return
this
;
}
}
...
...
gcc/go/gofrontend/statements.cc
View file @
16f72d88
...
@@ -421,6 +421,28 @@ Temporary_statement::do_check_types(Gogo*)
...
@@ -421,6 +421,28 @@ Temporary_statement::do_check_types(Gogo*)
}
}
}
}
// Flatten a temporary statement: add another temporary when it might
// be needed for interface conversion.
Statement
*
Temporary_statement
::
do_flatten
(
Gogo
*
,
Named_object
*
,
Block
*
,
Statement_inserter
*
inserter
)
{
if
(
this
->
type_
!=
NULL
&&
this
->
init_
!=
NULL
&&
!
Type
::
are_identical
(
this
->
type_
,
this
->
init_
->
type
(),
false
,
NULL
)
&&
this
->
init_
->
type
()
->
interface_type
()
!=
NULL
&&
!
this
->
init_
->
is_variable
())
{
Temporary_statement
*
temp
=
Statement
::
make_temporary
(
NULL
,
this
->
init_
,
this
->
location
());
inserter
->
insert
(
temp
);
this
->
init_
=
Expression
::
make_temporary_reference
(
temp
,
this
->
location
());
}
return
this
;
}
// Convert to backend representation.
// Convert to backend representation.
Bstatement
*
Bstatement
*
...
@@ -440,9 +462,10 @@ Temporary_statement::do_get_backend(Translate_context* context)
...
@@ -440,9 +462,10 @@ Temporary_statement::do_get_backend(Translate_context* context)
binit
=
this
->
init_
->
get_backend
(
context
);
binit
=
this
->
init_
->
get_backend
(
context
);
else
else
{
{
Expression
*
init
=
Expression
::
make_cast
(
this
->
type_
,
this
->
init_
,
Expression
*
init
=
Expression
::
convert_for_assignment
(
context
->
gogo
(),
this
->
location
());
this
->
type_
,
context
->
gogo
()
->
lower_expression
(
context
->
function
(),
NULL
,
&
init
);
this
->
init_
,
this
->
location
());
binit
=
init
->
get_backend
(
context
);
binit
=
init
->
get_backend
(
context
);
}
}
...
...
gcc/go/gofrontend/statements.h
View file @
16f72d88
...
@@ -550,6 +550,9 @@ class Temporary_statement : public Statement
...
@@ -550,6 +550,9 @@ class Temporary_statement : public Statement
void
void
do_check_types
(
Gogo
*
);
do_check_types
(
Gogo
*
);
Statement
*
do_flatten
(
Gogo
*
,
Named_object
*
,
Block
*
,
Statement_inserter
*
);
Bstatement
*
Bstatement
*
do_get_backend
(
Translate_context
*
);
do_get_backend
(
Translate_context
*
);
...
...
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