From patchwork Mon Nov 30 20:14:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 1408468 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=HE59qhUz; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4ClGgJ3K62z9sVk for ; Tue, 1 Dec 2020 07:15:06 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3A92C3892014; Mon, 30 Nov 2020 20:15:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A92C3892014 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1606767304; bh=4cxkywoxFUIOxv4eSTOp9eG4xoE/LBqvIHNuYzylwLg=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=HE59qhUzd6ShFcL8mF5G7gK9NKYhSEKs4X2sxHER/jZtQ0rH0jQMEmjgiV4Pm4A+W f3iDhZPqY1ibCgGZC1DZ228KZv7xyT7yFE8jISrU1ZDd35Td8PUoMWvBcCNyfDJdoA A+l2eUxYCyFOKx9uSCtjMYOuCKqBvpju2fpfIHWk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id 6D92D385DC2E for ; Mon, 30 Nov 2020 20:15:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6D92D385DC2E Received: by mail-ej1-x62a.google.com with SMTP id f23so4341925ejt.8 for ; Mon, 30 Nov 2020 12:15:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=4cxkywoxFUIOxv4eSTOp9eG4xoE/LBqvIHNuYzylwLg=; b=kNk3Nh6BEyIbfhd6WpTiQAfhwiqbT7pdiuLfBx4HRt4lwbaYY/jiboGlF/0wv1sR8V 5pFYVKwKcmizGNbFk7F2u2/2hHFgf4KlMI1OygO14D8irSJY98zjUF6hCj8RJw9GfY1m E1wV6nEwQB2/L5/bw2ckXHa0kO5//zMtY3CPAfIr3BMwGIRElQT2qIqornK39omdzRN5 sReyL95yMzvr3zKY3icIZlcmzlwWoc0v4YYjpI4KXbaYIWrrcUoQvHpWRyYA/gj+L1Cf sQwO1GptF+fG7yMZDhPmBwyzD2GJcScwQ6OZy365jd4IQ4zhvG2l5CcEkn5zh1y6o40e 6Sdg== X-Gm-Message-State: AOAM533zeDcBGfxjwURzCa/tnD4zLJR0e5JDwUCo+Kc/AkIq0D1rngNq chypi+eCQw0RTdUJDYAv2B2qaR6BMp/dDp1oJbOla7sQSSlskA== X-Google-Smtp-Source: ABdhPJy70jatekkUHqp8LF4iP4zIjOHnEvGG1+pQFPgpXRTat0TDjteSl5GX4OLf5rhA1MsVWenKFtN/ZCJJz8ullTo= X-Received: by 2002:a17:906:e093:: with SMTP id gh19mr18268279ejb.510.1606767300300; Mon, 30 Nov 2020 12:15:00 -0800 (PST) MIME-Version: 1.0 Date: Mon, 30 Nov 2020 12:14:48 -0800 Message-ID: Subject: Go patch committed: Improve error messages for expected curly brace To: gcc-patches , gofrontend-dev X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ian Lance Taylor via Gcc-patches From: Ian Lance Taylor Reply-To: Ian Lance Taylor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This Go frontend patch improves the error messages for an expected curly brace. This is for https://golang.org/issue/17328. This requires updating some tests to the current sources in the main repo. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 5ba975e6680cc5f9c2be7ee34b1cacdba3eb3347 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index e2fc0b5560b..41246030f13 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -213abeedc85ed638a878f9457e422897fda3a111 +45461eeba1db1a3b4194dc8ecc331c0e92f5ad4c 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/parse.cc b/gcc/go/gofrontend/parse.cc index 1dac0029feb..c9a5485049f 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -4422,7 +4422,7 @@ Parse::if_stat() { Location semi_loc = this->location(); if (this->advance_token()->is_op(OPERATOR_LCURLY)) - go_error_at(semi_loc, "missing %<{%> after if clause"); + go_error_at(semi_loc, "unexpected semicolon or newline, expecting %<{%> after if clause"); // Otherwise we will get an error when we call this->block // below. } @@ -5359,7 +5359,7 @@ Parse::for_stat(Label* label) { Location semi_loc = this->location(); if (this->advance_token()->is_op(OPERATOR_LCURLY)) - go_error_at(semi_loc, "missing %<{%> after for clause"); + go_error_at(semi_loc, "unexpected semicolon or newline, expecting %<{%> after for clause"); // Otherwise we will get an error when we call this->block // below. } @@ -5430,7 +5430,7 @@ Parse::for_clause(Expression** cond, Block** post) *cond = NULL; else if (this->peek_token()->is_op(OPERATOR_LCURLY)) { - go_error_at(this->location(), "missing %<{%> after for clause"); + go_error_at(this->location(), "unexpected semicolon or newline, expecting %<{%> after for clause"); *cond = NULL; *post = NULL; return; diff --git a/gcc/testsuite/go.test/test/syntax/semi1.go b/gcc/testsuite/go.test/test/syntax/semi1.go index 6e0428121ff..8eed05c1ca1 100644 --- a/gcc/testsuite/go.test/test/syntax/semi1.go +++ b/gcc/testsuite/go.test/test/syntax/semi1.go @@ -1,13 +1,13 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func main() { - if x; y // ERROR "missing .*{.* after if clause|undefined" + if x; y // ERROR "expected .*{.* after if clause|undefined" { z // GCCGO_ERROR "undefined" diff --git a/gcc/testsuite/go.test/test/syntax/semi3.go b/gcc/testsuite/go.test/test/syntax/semi3.go index ca070d8a577..d064ce631c9 100644 --- a/gcc/testsuite/go.test/test/syntax/semi3.go +++ b/gcc/testsuite/go.test/test/syntax/semi3.go @@ -1,13 +1,13 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func main() { - for x; y; z // ERROR "missing .*{.* after for clause|undefined" + for x; y; z // ERROR "expected .*{.* after for clause|undefined" { z // GCCGO_ERROR "undefined" diff --git a/gcc/testsuite/go.test/test/syntax/semi4.go b/gcc/testsuite/go.test/test/syntax/semi4.go index 99c2d22561b..08c354751b6 100644 --- a/gcc/testsuite/go.test/test/syntax/semi4.go +++ b/gcc/testsuite/go.test/test/syntax/semi4.go @@ -1,6 +1,6 @@ // errorcheck -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -8,7 +8,5 @@ package main func main() { for x // GCCGO_ERROR "undefined" - { // ERROR "missing .*{.* after for clause" + { // ERROR "unexpected {, expecting for loop condition|expecting .*{.* after for clause" z // GCCGO_ERROR "undefined" - -