aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-04-28 04:56:55 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-04-28 04:56:55 +0000
commit69f232c5a1a432d133431720f19c233cb20d8079 (patch)
tree44c7a0848e4d40359a0c29b84c9292f3f270dd32 /gcc/go
parentfa06ad0d58e8981afc7dd0e8965505bab04a5320 (diff)
downloadgcc-69f232c5a1a432d133431720f19c233cb20d8079.zip
gcc-69f232c5a1a432d133431720f19c233cb20d8079.tar.gz
gcc-69f232c5a1a432d133431720f19c233cb20d8079.tar.bz2
compiler: Fix some crashes on invalid code.
Fixes issue 7. From-SVN: r186929
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/expressions.cc2
-rw-r--r--gcc/go/gofrontend/types.cc11
2 files changed, 11 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 6bd00a8..a266694 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -9225,7 +9225,7 @@ Call_expression::set_results(Translate_context* context, tree call_tree)
ref->set_is_lvalue();
tree temp_tree = ref->get_tree(context);
if (temp_tree == error_mark_node)
- continue;
+ return error_mark_node;
tree val_tree = build3_loc(loc.gcc_location(), COMPONENT_REF,
TREE_TYPE(field), call_tree, field, NULL_TREE);
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index 9e64a6a..74bab41 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -5450,6 +5450,11 @@ Array_type::get_length_tree(Gogo* gogo)
mpz_t val;
if (this->length_->numeric_constant_value(&nc) && nc.to_int(&val))
{
+ if (mpz_sgn(val) < 0)
+ {
+ this->length_tree_ = error_mark_node;
+ return this->length_tree_;
+ }
Type* t = nc.type();
if (t == NULL)
t = Type::lookup_integer_type("int");
@@ -6551,7 +6556,11 @@ bool
Interface_type::is_identical(const Interface_type* t,
bool errors_are_identical) const
{
- go_assert(this->methods_are_finalized_ && t->methods_are_finalized_);
+ // If methods have not been finalized, then we are asking whether
+ // func redeclarations are the same. This is an error, so for
+ // simplicity we say they are never the same.
+ if (!this->methods_are_finalized_ || !t->methods_are_finalized_)
+ return false;
// We require the same methods with the same types. The methods
// have already been sorted.