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 invalid use of multiple results
- 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: Thu, 23 Dec 2010 16:51:13 -0800
- Subject: Go patch committed: Don't crash on invalid use of multiple results
There were some cases in the Go frontend where an invalid use of a
function call returning multiple results could cause the compiler to
crash. For example, it could happen when returning multiple results in
a function which returned an interface type. This patch avoids the
crashes in invalid programs. Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu. Committed to mainline.
Ian
diff -r 5382ded0e9b4 go/types.cc
--- a/go/types.cc Thu Dec 23 16:32:07 2010 -0800
+++ b/go/types.cc Thu Dec 23 16:46:39 2010 -0800
@@ -3253,26 +3253,35 @@
protected:
bool
do_has_pointer() const
- { gcc_unreachable(); }
+ {
+ gcc_assert(saw_errors());
+ return false;
+ }
tree
do_get_tree(Gogo*);
tree
do_get_init_tree(Gogo*, tree, bool)
- { gcc_unreachable(); }
+ {
+ gcc_assert(saw_errors());
+ return error_mark_node;
+ }
Expression*
do_type_descriptor(Gogo*, Named_type*)
- { gcc_unreachable(); }
+ {
+ gcc_assert(saw_errors());
+ return Expression::make_error(UNKNOWN_LOCATION);
+ }
void
do_reflection(Gogo*, std::string*) const
- { gcc_unreachable(); }
+ { gcc_assert(saw_errors()); }
void
do_mangled_name(Gogo*, std::string*) const
- { gcc_unreachable(); }
+ { gcc_assert(saw_errors()); }
private:
// The expression being called.