From patchwork Mon Nov 30 20:00:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 1408463 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=8.43.85.97; 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=MJa1QjNU; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 4ClGM60PRfz9sVq for ; Tue, 1 Dec 2020 07:01:04 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A7763393BC37; Mon, 30 Nov 2020 20:01:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7763393BC37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1606766461; bh=AiW8PLCjUDDTsdoQt5i+2ul0xQ+IFw9RJXt9Vcq6NCg=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=MJa1QjNUcGD1qstKuMaPoq5dakHdAEymvLzeJAMNsfBkvxdDnMGdidOe6dOSZ/94h 1nWcNydbsIJ3UH0RBXs8C6yATUzamtHMR7eYba7HEVBl8MIfJvkBJQ/+zrLRHnDeL/ TbIY6c2AXL4xepaK8AOedQCt2Fg7eC10H466Zb+c= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 6BBCC393BC33 for ; Mon, 30 Nov 2020 20:00:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6BBCC393BC33 Received: by mail-ed1-x533.google.com with SMTP id q16so17920080edv.10 for ; Mon, 30 Nov 2020 12:00:58 -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=AiW8PLCjUDDTsdoQt5i+2ul0xQ+IFw9RJXt9Vcq6NCg=; b=IBEHLmIapJLVN76iGS+KFpPB9qZOJo/iqr+SyZ+MM5+NlBYVWbJORJYkBDXP0R6k67 3er1VFYzPuJHZVGK7VTFas2pvNDnS8fAzrp0sM/ZDQmMGNoj0UvfPFNiw6vqRb9WbVB/ 2Q53LsHWE0TmjrhUCv10u2wBmsRjmrs22AnnkyqXh4BZLi799+NJMX3FuQ5VcgfFqYTV Re3hU4lrMyu2WIrX8J8Rz33pPnvMXD2z93FojiHkKeoqGlRSd4kYQhj5kgRA/SVwIzvv zAKg0YxliE1CBmJuhjZ1bXJenKWb+LW0XZUYJqHofzMRK7YyA5ri8Gi6BN4wKFaA/jIX pIeQ== X-Gm-Message-State: AOAM533plce7r9RiwUr3vPQVmkMnpN+yfqUoZGY8GcCfVEHD3bsScL2u I81VzYA2BOpl1Nv0dkSiFOPEX8jZjAswL88T8bAcNnKIB2eV6A== X-Google-Smtp-Source: ABdhPJzyfLuLC8g3d4UJ8S+3IjmI2mtjHKror8KB3E6DPZA6CjU06N3Gdxqh6YeDEdtVUdx8z8jcthDJeaeBGYmJSPE= X-Received: by 2002:a50:a6dd:: with SMTP id f29mr12643027edc.257.1606766456736; Mon, 30 Nov 2020 12:00:56 -0800 (PST) MIME-Version: 1.0 Date: Mon, 30 Nov 2020 12:00:44 -0800 Message-ID: Subject: Go patch committed: Improve error for import of non-string 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 patch to the Go frontend improves the error message when using an import statement with something other than a string. This requires updating one of the tests to the current version in the main repo. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 4f32eced9d01c610bd53e8c59b83bcb5402eddb5 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 46959070e85..c14a10f1265 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -16ab9b001c214cf831bc52a7bca5a2d18e9e4f3c +534fb907c821b052dc430330708d7fa555b91fe3 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 aa157e86cb2..1dac0029feb 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -5788,7 +5788,7 @@ Parse::import_spec(void*, unsigned int pragmas) if (!token->is_string()) { - go_error_at(this->location(), "import statement not a string"); + go_error_at(this->location(), "import path must be a string"); this->advance_token(); return; } diff --git a/gcc/testsuite/go.test/test/import5.go b/gcc/testsuite/go.test/test/import5.go index 6480acff92c..8fdc8c37574 100644 --- a/gcc/testsuite/go.test/test/import5.go +++ b/gcc/testsuite/go.test/test/import5.go @@ -21,35 +21,7 @@ import _ "go/parser" //import "greek/αβ" // Import paths must be strings. -import 42 // ERROR "import statement" -import 'a' // ERROR "import statement" -import 3.14 // ERROR "import statement" -import 0.25i // ERROR "import statement" - -// Each of these pairs tests both `` vs "" strings -// and also use of invalid characters spelled out as -// escape sequences and written directly. -// For example `"\x00"` tests import "\x00" -// while "`\x00`" tests import ``. -import "" // ERROR "import path" -import `` // ERROR "import path" -import "\x00" // ERROR "import path" -import `\x00` // ERROR "import path" -import "\x7f" // ERROR "import path" -import `\x7f` // ERROR "import path" -import "a!" // ERROR "import path" -import `a!` // ERROR "import path" -import "a b" // ERROR "import path" -import `a b` // ERROR "import path" -import "a\\b" // ERROR "import path" -import `a\\b` // ERROR "import path" -import "\"`a`\"" // ERROR "import path" -import `\"a\"` // ERROR "import path" -import "\x80\x80" // ERROR "import path" -import `\x80\x80` // ERROR "import path" -import "\xFFFD" // ERROR "import path" -import `\xFFFD` // ERROR "import path" - -// Invalid local imports. -import "/foo" // ERROR "import path cannot be absolute path" -import "c:/foo" // ERROR "import path contains invalid character" +import 42 // ERROR "import path must be a string" +import 'a' // ERROR "import path must be a string" +import 3.14 // ERROR "import path must be a string" +import 0.25i // ERROR "import path must be a string"