aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2013-08-07 19:01:16 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2013-08-07 19:01:16 +0000
commit364ed4bac6400aa6645064c6b9e7e518f08dab54 (patch)
tree4fdcc767cf3efa1928a8fcdd124138d160565ba6 /gcc/go
parent5cf6635b26c757412e1a3124c604c9ccb319ff9d (diff)
downloadgcc-364ed4bac6400aa6645064c6b9e7e518f08dab54.zip
gcc-364ed4bac6400aa6645064c6b9e7e518f08dab54.tar.gz
gcc-364ed4bac6400aa6645064c6b9e7e518f08dab54.tar.bz2
compiler: Fix "missing return" error for case T1, T2 in type switches.
Also change the "missing return" text and report it at the end of the function, rather than the start, to match the gc compiler. From-SVN: r201579
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/gogo.cc3
-rw-r--r--gcc/go/gofrontend/statements.cc10
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc
index 0b69d5d..4e5bd44 100644
--- a/gcc/go/gofrontend/gogo.cc
+++ b/gcc/go/gofrontend/gogo.cc
@@ -3133,7 +3133,8 @@ Check_return_statements_traverse::function(Named_object* no)
return TRAVERSE_CONTINUE;
if (func->block()->may_fall_through())
- error_at(func->location(), "control reaches end of non-void function");
+ error_at(func->block()->end_location(),
+ "missing return at end of function");
return TRAVERSE_CONTINUE;
}
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index ca1ad07..7314918 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -4093,6 +4093,16 @@ Type_case_clauses::Type_case_clause::lower(Type* switch_val_type,
bool
Type_case_clauses::Type_case_clause::may_fall_through() const
{
+ if (this->is_fallthrough_)
+ {
+ // This case means that we automatically fall through to the
+ // next case (it's used for T1 in case T1, T2:). It does not
+ // mean that we fall through to the end of the type switch as a
+ // whole. There is sure to be a next case and that next case
+ // will determine whether we fall through to the statements
+ // after the type switch.
+ return false;
+ }
if (this->statements_ == NULL)
return true;
return this->statements_->may_fall_through();