From patchwork Fri Mar 13 20:48:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 450100 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 20BFB1400DD for ; Sat, 14 Mar 2015 07:49:04 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=OS0Vk8XJ; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=DwtdZyK64mN3TpqijB9eMCysjI2i6rL0IUDDftmpZw3f7u 0Em84Qq0DhgEkU6LAPNPl9ufw/FPW8JdZlW4NCu6NsCWChDMQOLClDZxlSOxgdXP gHt+OyVVAbKpbBH7A09ktDP7DAzyIuThSinx4JysVGHp6KpyebFhSpzJg0FIU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=LNwIc8DM4RXcLyFJoP3LyFbYgrE=; b=OS0Vk8XJwN2Mk9X24/QH HMfbnyE2TvTheyvzvxnTwRypBevblsVmteeyKkSOEJI6Oy/kCjj5z+3B0/A4JRKX Fkh6Pi4lO3IZaZINZSNBc4B7owmkJMQpM8m8GALkWWo6WCBudk5htshsCqwzSA3j sXndIo7gm89If/faUPqXIAQ= Received: (qmail 79832 invoked by alias); 13 Mar 2015 20:48:55 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 79809 invoked by uid 89); 13 Mar 2015 20:48:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yh0-f42.google.com Received: from mail-yh0-f42.google.com (HELO mail-yh0-f42.google.com) (209.85.213.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 13 Mar 2015 20:48:53 +0000 Received: by yhab6 with SMTP id b6so2896136yha.9 for ; Fri, 13 Mar 2015 13:48:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=RjGqJF7n4jLjfN83jdLAsKwdwktSAi06xX7+wv3rtBc=; b=OZ9hLgBGZ1lChdszDylIDX1/XdDEMuQpZ643OKGIJFPTo1H16K6YEY7fm6y7PeaBOj vreq0J4hOTUsWCmu8NU1yzk4U1SBO4kvO898niJvmMJNyJsGzm9b4gygtlfmKK7mbDd0 +dGBFdmVBct8OXyzutgd+vpDCY2GcDlCGY6Ix0xhDOyiF3t9Lh+iRN2w06nQC5vVfrYn sq6a1jM6N33mDnbs9P/PbgKHhk1iSEGaxN77gPKUOsuQBKh796F4HQUpfrZHsmnLaooG Hnng3T9nkUvPauI6h7mvGgd1wumvagF+l9Dphy/tiZIciNqdp/h5TkKDZi60Rl96TIMx pytA== X-Gm-Message-State: ALoCoQkd0oGL7Of9gCscNQUxIcMfrraDbDTxwBRqC5tbjDSmma5XNwl//psJTR4ALTwiVvg4sPO9 MIME-Version: 1.0 X-Received: by 10.236.21.163 with SMTP id r23mr47841371yhr.141.1426279731615; Fri, 13 Mar 2015 13:48:51 -0700 (PDT) Received: by 10.170.230.205 with HTTP; Fri, 13 Mar 2015 13:48:51 -0700 (PDT) Date: Fri, 13 Mar 2015 13:48:51 -0700 Message-ID: Subject: Go patch committed: Permit label on fallthrough statement From: Ian Lance Taylor To: gcc-patches , "gofrontend-dev@googlegroups.com" The gccgo parser had a bug: it rejected labels on fallthrough statements, because those statements can only appear in specific contexts (at the end of a switch block just before the next case statement). This patch fixes the problem. I will add a test to the master testsuite for this, which will be brought into the gccgo testsuite in due course (https://go-review.googlesource.com/7523). Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 52642b1b9500 go/parse.cc --- a/go/parse.cc Fri Mar 13 11:52:24 2015 -0700 +++ b/go/parse.cc Fri Mar 13 13:43:52 2015 -0700 @@ -3735,6 +3735,17 @@ if (!this->statement_may_start_here()) { + if (this->peek_token()->is_keyword(KEYWORD_FALLTHROUGH)) + { + // We don't treat the fallthrough keyword as a statement, + // because it can't appear most places where a statement is + // permitted, but it may have a label. We introduce a + // semicolon because the caller expects to see a statement. + this->unget_token(Token::make_operator_token(OPERATOR_SEMICOLON, + location)); + return; + } + // Mark the label as used to avoid a useless error about an // unused label. if (label != NULL)