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
34d9bc34
Commit
34d9bc34
authored
Dec 23, 2010
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid infinite recursion checking whether field is exported.
From-SVN: r168191
parent
62d1a8f9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
7 deletions
+35
-7
gcc/go/gofrontend/types.cc
+33
-6
gcc/go/gofrontend/types.h
+2
-1
No files found.
gcc/go/gofrontend/types.cc
View file @
34d9bc34
...
...
@@ -7686,8 +7686,10 @@ Type::bind_field_or_method(Gogo* gogo, const Type* type, Expression* expr,
else
{
std
::
string
unpacked
=
Gogo
::
unpack_hidden_name
(
name
);
seen
.
clear
();
is_unexported
=
Type
::
is_unexported_field_or_method
(
gogo
,
type
,
unpacked
);
unpacked
,
&
seen
);
}
if
(
is_unexported
)
error_at
(
location
,
"reference to unexported field or method %qs"
,
...
...
@@ -7905,13 +7907,28 @@ Type::find_field_or_method(const Type* type,
bool
Type
::
is_unexported_field_or_method
(
Gogo
*
gogo
,
const
Type
*
type
,
const
std
::
string
&
name
)
const
std
::
string
&
name
,
std
::
vector
<
const
Named_type
*>*
seen
)
{
type
=
type
->
deref
();
const
Named_type
*
nt
=
type
->
named_type
();
if
(
nt
!=
NULL
&&
nt
->
is_unexported_local_method
(
gogo
,
name
))
return
true
;
if
(
nt
!=
NULL
)
{
if
(
nt
->
is_unexported_local_method
(
gogo
,
name
))
return
true
;
for
(
std
::
vector
<
const
Named_type
*>::
const_iterator
p
=
seen
->
begin
();
p
!=
seen
->
end
();
++
p
)
{
if
(
*
p
==
nt
)
{
// We've already seen this type.
return
false
;
}
}
}
const
Interface_type
*
it
=
type
->
interface_type
();
if
(
it
!=
NULL
&&
it
->
is_unexported_method
(
gogo
,
name
))
...
...
@@ -7928,6 +7945,9 @@ Type::is_unexported_field_or_method(Gogo* gogo, const Type* type,
if
(
fields
==
NULL
)
return
false
;
if
(
nt
!=
NULL
)
seen
->
push_back
(
nt
);
for
(
Struct_field_list
::
const_iterator
pf
=
fields
->
begin
();
pf
!=
fields
->
end
();
++
pf
)
...
...
@@ -7938,11 +7958,18 @@ Type::is_unexported_field_or_method(Gogo* gogo, const Type* type,
{
Named_type
*
subtype
=
pf
->
type
()
->
deref
()
->
named_type
();
gcc_assert
(
subtype
!=
NULL
);
if
(
Type
::
is_unexported_field_or_method
(
gogo
,
subtype
,
name
))
return
true
;
if
(
Type
::
is_unexported_field_or_method
(
gogo
,
subtype
,
name
,
seen
))
{
if
(
nt
!=
NULL
)
seen
->
pop_back
();
return
true
;
}
}
}
if
(
nt
!=
NULL
)
seen
->
pop_back
();
return
false
;
}
...
...
gcc/go/gofrontend/types.h
View file @
34d9bc34
...
...
@@ -791,7 +791,8 @@ class Type
// Return true if NAME is an unexported field or method of TYPE.
static
bool
is_unexported_field_or_method
(
Gogo
*
,
const
Type
*
,
const
std
::
string
&
);
is_unexported_field_or_method
(
Gogo
*
,
const
Type
*
,
const
std
::
string
&
,
std
::
vector
<
const
Named_type
*>*
);
// This type was passed to the builtin function make. ARGS are the
// arguments passed to make after the type; this may be NULL if
...
...
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