From: Ian Lance Taylor Date: Thu, 23 Dec 2010 00:40:29 +0000 (+0000) Subject: Don't crash asking for type of invalid const. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8211d03c0b0c23b883e4a2630d2e6e9478b12796;p=gcc.git Don't crash asking for type of invalid const. From-SVN: r168194 --- diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 8592ef546b9..23f6e2ba47e 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -894,6 +894,19 @@ Expression::make_type(Type* type, source_location location) return new Type_expression(type, location); } +// Class Parser_expression. + +Type* +Parser_expression::do_type() +{ + // We should never really ask for the type of a Parser_expression. + // However, it can happen, at least when we have an invalid const + // whose initializer refers to the const itself. In that case we + // may ask for the type when lowering the const itself. + gcc_assert(saw_errors()); + return Type::make_error_type(); +} + // Class Var_expression. // Lower a variable expression. Here we just make sure that the diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index 4780a8b834f..fe4ade2c99d 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -873,8 +873,7 @@ class Parser_expression : public Expression do_lower(Gogo*, Named_object*, int) = 0; Type* - do_type() - { gcc_unreachable(); } + do_type(); void do_determine_type(const Type_context*)