This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Don't crash on type descriptor of abstract type
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Wed, 02 Mar 2011 20:25:50 -0800
- Subject: Go patch committed: Don't crash on type descriptor of abstract type
It's possible for erroneous code to attempt to get a type descriptor of
an abstract type. This patch to the Go frontend avoids crashing when
that happens. Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu. Committed to mainline.
Ian
diff -r 61c84c273f21 go/types.cc
--- a/go/types.cc Wed Mar 02 19:30:37 2011 -0800
+++ b/go/types.cc Wed Mar 02 19:57:21 2011 -0800
@@ -1764,7 +1764,12 @@
tree
Integer_type::do_get_tree(Gogo*)
{
- gcc_assert(!this->is_abstract_);
+ if (this->is_abstract_)
+ {
+ gcc_assert(saw_errors());
+ return error_mark_node;
+ }
+
if (this->is_unsigned_)
{
if (this->bits_ == INT_TYPE_SIZE)
@@ -1818,7 +1823,7 @@
void
Integer_type::do_reflection(Gogo*, std::string*) const
{
- gcc_unreachable();
+ gcc_assert(saw_errors());
}
// Mangled name.
@@ -1974,7 +1979,7 @@
void
Float_type::do_reflection(Gogo*, std::string*) const
{
- gcc_unreachable();
+ gcc_assert(saw_errors());
}
// Mangled name.
@@ -2134,7 +2139,7 @@
void
Complex_type::do_reflection(Gogo*, std::string*) const
{
- gcc_unreachable();
+ gcc_assert(saw_errors());
}
// Mangled name.