diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2017-09-15 21:25:17 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2017-09-15 21:25:17 +0000 |
commit | 7fdaa1f0b873b79ee87ad910b0da8e4c5f194cb0 (patch) | |
tree | dc50a2e5e02ec3272517b470a35702f0f3385728 /gcc | |
parent | 026a79f70cf33f836ea5275eda72d4870a3041e5 (diff) | |
download | gcc-7fdaa1f0b873b79ee87ad910b0da8e4c5f194cb0.zip gcc-7fdaa1f0b873b79ee87ad910b0da8e4c5f194cb0.tar.gz gcc-7fdaa1f0b873b79ee87ad910b0da8e4c5f194cb0.tar.bz2 |
compiler: call error_statement for fallthrough in last case
It is possible to do this check in backend, by walking the
block and check whether the last statement is a goto. But it
seems easier to do it in the frontend, where it can simply use
is_fallthrough.
Reviewed-on: https://go-review.googlesource.com/63690
From-SVN: r252851
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | gcc/go/gofrontend/statements.cc | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index a63d921..aafc526 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -de7b370901c4fc6852eaa7372282bb699429ec4a +70cf67704699c8bcaf6f52437812367cdc4ad169 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc index eb370f8..bea57cd 100644 --- a/gcc/go/gofrontend/statements.cc +++ b/gcc/go/gofrontend/statements.cc @@ -3707,6 +3707,12 @@ Case_clauses::get_backend(Translate_context* context, std::vector<Bexpression*> cases; Bstatement* stat = p->get_backend(context, break_label, &case_constants, &cases); + // The final clause can't fall through. + if (i == c - 1 && p->is_fallthrough()) + { + go_assert(saw_errors()); + stat = context->backend()->error_statement(); + } (*all_cases)[i].swap(cases); (*all_statements)[i] = stat; } |