public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Go patch committed: Improve error for import of non-string
@ 2020-11-30 20:00 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2020-11-30 20:00 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 293 bytes --]

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

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2757 bytes --]

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 `<actual-NUL-byte>`.
-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"

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-30 20:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-30 20:00 Go patch committed: Improve error for import of non-string Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).