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
c7e529d3
Commit
c7e529d3
authored
Mar 07, 2011
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support multiple init functions in a single file.
From-SVN: r170756
parent
b4ed5986
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
21 deletions
+19
-21
gcc/go/gofrontend/gogo-tree.cc
+0
-13
gcc/go/gofrontend/gogo.cc
+19
-8
No files found.
gcc/go/gofrontend/gogo-tree.cc
View file @
c7e529d3
...
@@ -839,19 +839,6 @@ Named_object::get_id(Gogo* gogo)
...
@@ -839,19 +839,6 @@ Named_object::get_id(Gogo* gogo)
// types.
// types.
decl_name
=
Gogo
::
unpack_hidden_name
(
this
->
name_
);
decl_name
=
Gogo
::
unpack_hidden_name
(
this
->
name_
);
}
}
else
if
(
this
->
is_function
()
&&
!
this
->
func_value
()
->
is_method
()
&&
this
->
package_
==
NULL
&&
Gogo
::
unpack_hidden_name
(
this
->
name_
)
==
"init"
)
{
// A single package can have multiple "init" functions, which
// means that we need to give them different names.
static
int
init_index
;
char
buf
[
20
];
snprintf
(
buf
,
sizeof
buf
,
"%d"
,
init_index
);
++
init_index
;
decl_name
=
gogo
->
package_name
()
+
".init."
+
buf
;
}
else
else
{
{
std
::
string
package_name
;
std
::
string
package_name
;
...
...
gcc/go/gofrontend/gogo.cc
View file @
c7e529d3
...
@@ -211,12 +211,6 @@ Gogo::Gogo(int int_type_size, int pointer_size)
...
@@ -211,12 +211,6 @@ Gogo::Gogo(int int_type_size, int pointer_size)
this
->
globals_
->
add_function_declaration
(
"imag"
,
NULL
,
imag_type
,
loc
);
this
->
globals_
->
add_function_declaration
(
"imag"
,
NULL
,
imag_type
,
loc
);
this
->
define_builtin_function_trees
();
this
->
define_builtin_function_trees
();
// Declare "init", to ensure that it is not defined with parameters
// or return values.
this
->
declare_function
(
"init"
,
Type
::
make_function_type
(
NULL
,
NULL
,
NULL
,
loc
),
loc
);
}
}
// Munge name for use in an error message.
// Munge name for use in an error message.
...
@@ -660,7 +654,24 @@ Gogo::start_function(const std::string& name, Function_type* type,
...
@@ -660,7 +654,24 @@ Gogo::start_function(const std::string& name, Function_type* type,
const
std
::
string
*
pname
;
const
std
::
string
*
pname
;
std
::
string
nested_name
;
std
::
string
nested_name
;
if
(
!
name
.
empty
())
bool
is_init
=
false
;
if
(
Gogo
::
unpack_hidden_name
(
name
)
==
"init"
&&
!
type
->
is_method
())
{
if
((
type
->
parameters
()
!=
NULL
&&
!
type
->
parameters
()
->
empty
())
||
(
type
->
results
()
!=
NULL
&&
!
type
->
results
()
->
empty
()))
error_at
(
location
,
"func init must have no arguments and no return values"
);
// There can be multiple "init" functions, so give them each a
// different name.
static
int
init_count
;
char
buf
[
30
];
snprintf
(
buf
,
sizeof
buf
,
".$init%d"
,
init_count
);
++
init_count
;
nested_name
=
buf
;
pname
=
&
nested_name
;
is_init
=
true
;
}
else
if
(
!
name
.
empty
())
pname
=
&
name
;
pname
=
&
name
;
else
else
{
{
...
@@ -753,7 +764,7 @@ Gogo::start_function(const std::string& name, Function_type* type,
...
@@ -753,7 +764,7 @@ Gogo::start_function(const std::string& name, Function_type* type,
of
.
function
=
ret
;
of
.
function
=
ret
;
of
.
blocks
.
push_back
(
block
);
of
.
blocks
.
push_back
(
block
);
if
(
!
type
->
is_method
()
&&
Gogo
::
unpack_hidden_name
(
name
)
==
"init"
)
if
(
is_init
)
{
{
this
->
init_functions_
.
push_back
(
ret
);
this
->
init_functions_
.
push_back
(
ret
);
this
->
need_init_fn_
=
true
;
this
->
need_init_fn_
=
true
;
...
...
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