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
2a3b37c3
Commit
2a3b37c3
authored
Dec 15, 2010
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a different identity function for Types in hash tables.
From-SVN: r167866
parent
140806fa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
9 deletions
+39
-9
gcc/go/gofrontend/types.cc
+32
-8
gcc/go/gofrontend/types.h
+7
-1
No files found.
gcc/go/gofrontend/types.cc
View file @
2a3b37c3
...
@@ -393,6 +393,38 @@ Type::are_identical(const Type* t1, const Type* t2, std::string* reason)
...
@@ -393,6 +393,38 @@ Type::are_identical(const Type* t1, const Type* t2, std::string* reason)
}
}
}
}
// Return true if two types are identical when it comes to storing
// them in a hash table. This differs from Type::are_identical with
// regard to how we handle error types. We want to treat error types
// as identical to other types when it comes to reporting
// compatibility errors, but we want to treat them as different when
// it comes to storing them in a hash table.
bool
Type
::
are_identical_for_hash_table
(
const
Type
*
t1
,
const
Type
*
t2
)
{
if
(
t1
==
NULL
||
t2
==
NULL
)
return
t1
==
t2
;
t1
=
t1
->
forwarded
();
t2
=
t2
->
forwarded
();
if
(
t1
==
t2
)
return
true
;
// Undefined forward declarations are only equal to themselves.
if
(
t1
->
forward_declaration_type
()
!=
NULL
||
t2
->
forward_declaration_type
()
!=
NULL
)
return
false
;
// The error type is only equal to the error type.
if
(
t1
->
is_error_type
()
||
t2
->
is_error_type
())
return
t1
->
is_error_type
()
&&
t2
->
is_error_type
();
// Otherwise we can use the usual identity check.
return
Type
::
are_identical
(
t1
,
t2
,
NULL
);
}
// Return true if it's OK to have a binary operation with types LHS
// Return true if it's OK to have a binary operation with types LHS
// and RHS. This is not used for shifts or comparisons.
// and RHS. This is not used for shifts or comparisons.
...
@@ -810,14 +842,6 @@ Type::get_tree(Gogo* gogo)
...
@@ -810,14 +842,6 @@ Type::get_tree(Gogo* gogo)
tree
t
=
this
->
get_tree_without_hash
(
gogo
);
tree
t
=
this
->
get_tree_without_hash
(
gogo
);
// Don't store errors in the hash table. This type might be a
// pointer to an error type or something like that. Since error
// types are identical to everything else, that could cause us to
// return error_mark_node for pointers to any type, which will then
// confuse us later.
if
(
t
==
error_mark_node
)
return
error_mark_node
;
if
(
ins
.
first
->
second
==
NULL_TREE
)
if
(
ins
.
first
->
second
==
NULL_TREE
)
ins
.
first
->
second
=
t
;
ins
.
first
->
second
=
t
;
else
else
...
...
gcc/go/gofrontend/types.h
View file @
2a3b37c3
...
@@ -508,6 +508,12 @@ class Type
...
@@ -508,6 +508,12 @@ class Type
static
bool
static
bool
are_identical
(
const
Type
*
lhs
,
const
Type
*
rhs
,
std
::
string
*
reason
);
are_identical
(
const
Type
*
lhs
,
const
Type
*
rhs
,
std
::
string
*
reason
);
// Return true if two types are identical when it comes to putting
// them in a hash table. This differs from are_identical only in
// how error types are handled.
static
bool
are_identical_for_hash_table
(
const
Type
*
,
const
Type
*
);
// Return true if two types are compatible for use in a binary
// Return true if two types are compatible for use in a binary
// operation, other than a shift, comparison, or channel send. This
// operation, other than a shift, comparison, or channel send. This
// is an equivalence relation.
// is an equivalence relation.
...
@@ -1104,7 +1110,7 @@ class Type_identical
...
@@ -1104,7 +1110,7 @@ class Type_identical
public
:
public
:
bool
bool
operator
()(
const
Type
*
t1
,
const
Type
*
t2
)
const
operator
()(
const
Type
*
t1
,
const
Type
*
t2
)
const
{
return
Type
::
are_identical
(
t1
,
t2
,
NULL
);
}
{
return
Type
::
are_identical
_for_hash_table
(
t1
,
t2
);
}
};
};
// An identifier with a type.
// An identifier with a type.
...
...
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