This patch by Cherry Zhang changes the Go frontend to call error_statement when generating GIMPLE for a fallthrough in the last case in a switch. This avoids generating incorrect IR in an erroneous case. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline.
Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 252849) +++ gcc/go/gofrontend/MERGE (working copy) @@ -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. Index: gcc/go/gofrontend/statements.cc =================================================================== --- gcc/go/gofrontend/statements.cc (revision 252749) +++ gcc/go/gofrontend/statements.cc (working copy) @@ -3707,6 +3707,12 @@ Case_clauses::get_backend(Translate_cont 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; }