OSDN Git Service

Don't crash asking for type of invalid const.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Dec 2010 00:40:29 +0000 (00:40 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Dec 2010 00:40:29 +0000 (00:40 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@168194 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/expressions.cc
gcc/go/gofrontend/expressions.h

index 8592ef5..23f6e2b 100644 (file)
@@ -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
index 4780a8b..fe4ade2 100644 (file)
@@ -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*)