* Go patch committed: Don't crash if array length is invalid const
@ 2010-12-22 16:05 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2010-12-22 16:05 UTC (permalink / raw)
To: gcc-patches, gofrontend-dev
[-- Attachment #1: Type: text/plain, Size: 207 bytes --]
This patch to the Go frontend avoids a crash if the length of an array
is a const which turns out to be invalid. Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu. Committed to mainline.
Ian
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: invalid --]
[-- Type: text/x-diff, Size: 1090 bytes --]
diff -r 08ce2cd2cdcd go/expressions.cc
--- a/go/expressions.cc Wed Dec 22 07:08:44 2010 -0800
+++ b/go/expressions.cc Wed Dec 22 07:21:09 2010 -0800
@@ -9095,7 +9095,11 @@
this->report_error(_("slice end must be integer"));
Array_type* array_type = this->array_->type()->array_type();
- gcc_assert(array_type != NULL);
+ if (array_type == NULL)
+ {
+ gcc_assert(this->array_->type()->is_error_type());
+ return;
+ }
unsigned int int_bits =
Type::lookup_integer_type("int")->integer_type()->bits();
@@ -10936,7 +10940,14 @@
tree
Open_array_construction_expression::do_get_tree(Translate_context* context)
{
- Type* element_type = this->type()->array_type()->element_type();
+ Array_type* array_type = this->type()->array_type();
+ if (array_type == NULL)
+ {
+ gcc_assert(this->type()->is_error_type());
+ return error_mark_node;
+ }
+
+ Type* element_type = array_type->element_type();
tree element_type_tree = element_type->get_tree(context->gogo());
if (element_type_tree == error_mark_node)
return error_mark_node;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-12-22 15:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-22 16:05 Go patch committed: Don't crash if array length is invalid const Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).