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
2181e714
Commit
2181e714
authored
Feb 09, 2011
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The "main" package is not special if -fgo-prefix is used.
From-SVN: r169986
parent
15167bba
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
8 deletions
+25
-8
gcc/go/gofrontend/gogo-tree.cc
+6
-6
gcc/go/gofrontend/gogo.cc
+13
-2
gcc/go/gofrontend/gogo.h
+6
-0
No files found.
gcc/go/gofrontend/gogo-tree.cc
View file @
2181e714
...
...
@@ -161,7 +161,7 @@ Gogo::get_init_fn_name()
if
(
this
->
init_fn_name_
.
empty
())
{
gcc_assert
(
this
->
package_
!=
NULL
);
if
(
this
->
package_name
()
==
"main"
)
if
(
this
->
is_main_package
()
)
{
// Use a name which the runtime knows.
this
->
init_fn_name_
=
"__go_init_main"
;
...
...
@@ -186,7 +186,7 @@ Gogo::get_init_fn_name()
void
Gogo
::
init_imports
(
tree
*
init_stmt_list
)
{
gcc_assert
(
this
->
package_name
()
==
"main"
);
gcc_assert
(
this
->
is_main_package
()
);
if
(
this
->
imported_init_fns_
.
empty
())
return
;
...
...
@@ -384,7 +384,7 @@ Gogo::write_initialization_function(tree fndecl, tree init_stmt_list)
{
// Make sure that we thought we needed an initialization function,
// as otherwise we will not have reported it in the export data.
gcc_assert
(
this
->
package_name
()
==
"main"
||
this
->
need_init_fn_
);
gcc_assert
(
this
->
is_main_package
()
||
this
->
need_init_fn_
);
if
(
fndecl
==
NULL_TREE
)
fndecl
=
this
->
initialization_function_decl
();
...
...
@@ -648,7 +648,7 @@ Gogo::write_globals()
tree
init_fndecl
=
NULL_TREE
;
tree
init_stmt_list
=
NULL_TREE
;
if
(
this
->
package_name
()
==
"main"
)
if
(
this
->
is_main_package
()
)
this
->
init_imports
(
&
init_stmt_list
);
// A list of variable initializations.
...
...
@@ -804,7 +804,7 @@ Gogo::write_globals()
// This will be called if this package is imported.
if
(
init_stmt_list
!=
NULL_TREE
||
this
->
need_init_fn_
||
this
->
package_name
()
==
"main"
)
||
this
->
is_main_package
()
)
this
->
write_initialization_function
(
init_fndecl
,
init_stmt_list
);
// Pass everything back to the middle-end.
...
...
@@ -1259,7 +1259,7 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no, tree id)
&&
!
this
->
type_
->
is_method
())
;
else
if
(
Gogo
::
unpack_hidden_name
(
no
->
name
())
==
"main"
&&
gogo
->
package_name
()
==
"main"
)
&&
gogo
->
is_main_package
()
)
TREE_PUBLIC
(
decl
)
=
1
;
// Methods have to be public even if they are hidden because
// they can be pulled into type descriptors when using
...
...
gcc/go/gofrontend/gogo.cc
View file @
2181e714
...
...
@@ -33,6 +33,7 @@ Gogo::Gogo(int int_type_size, int pointer_size)
init_fn_name_
(),
imported_init_fns_
(),
unique_prefix_
(),
unique_prefix_specified_
(
false
),
interface_types_
()
{
const
source_location
loc
=
BUILTINS_LOCATION
;
...
...
@@ -259,7 +260,7 @@ Gogo::set_package_name(const std::string& package_name,
// package name (e.g., P.x), but we no longer do.
// this->globals_->add_package(package_name, this->package_);
if
(
package_name
==
"main"
)
if
(
this
->
is_main_package
()
)
{
// Declare "main" as a function which takes no parameters and
// returns no value.
...
...
@@ -270,6 +271,15 @@ Gogo::set_package_name(const std::string& package_name,
}
}
// Return whether this is the "main" package. This is not true if
// -fgo-prefix was used.
bool
Gogo
::
is_main_package
()
const
{
return
this
->
package_name
()
==
"main"
&&
!
this
->
unique_prefix_specified_
;
}
// Import a package.
void
...
...
@@ -2446,6 +2456,7 @@ Gogo::set_unique_prefix(const std::string& arg)
{
gcc_assert
(
this
->
unique_prefix_
.
empty
());
this
->
unique_prefix_
=
arg
;
this
->
unique_prefix_specified_
=
true
;
}
// Work out the package priority. It is one more than the maximum
...
...
@@ -2477,7 +2488,7 @@ Gogo::do_exports()
exp
.
export_globals
(
this
->
package_name
(),
this
->
unique_prefix
(),
this
->
package_priority
(),
(
this
->
need_init_fn_
&&
this
->
package_name
()
!=
"main"
(
this
->
need_init_fn_
&&
!
this
->
is_main_package
()
?
this
->
get_init_fn_name
()
:
""
),
this
->
imported_init_fns_
,
...
...
gcc/go/gofrontend/gogo.h
View file @
2181e714
...
...
@@ -112,6 +112,10 @@ class Gogo
void
set_package_name
(
const
std
::
string
&
,
source_location
);
// Return whether this is the "main" package.
bool
is_main_package
()
const
;
// If necessary, adjust the name to use for a hidden symbol. We add
// a prefix of the package name, so that hidden symbols in different
// packages do not collide.
...
...
@@ -653,6 +657,8 @@ class Gogo
std
::
set
<
Import_init
>
imported_init_fns_
;
// The unique prefix used for all global symbols.
std
::
string
unique_prefix_
;
// Whether an explicit unique prefix was set by -fgo-prefix.
bool
unique_prefix_specified_
;
// A list of interface types defined while parsing.
std
::
vector
<
Interface_type
*>
interface_types_
;
};
...
...
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