3 //go:build !nacl && !js && !wasip1 && gc
5 // Copyright 2015 The Go Authors. All rights reserved.
6 // Use of this source code is governed by a BSD-style
7 // license that can be found in the LICENSE file.
9 // Issue 11771: Magic comments should ignore carriage returns.
25 if runtime.Compiler != "gc" {
29 dir, err := ioutil.TempDir("", "go-issue11771")
31 log.Fatalf("creating temp dir: %v\n", err)
33 defer os.RemoveAll(dir)
35 // The go:nowritebarrier magic comment is only permitted in
36 // the runtime package. So we confirm that the compilation
46 fmt.Fprintln(&buf, "//go:nowritebarrier\r")
52 if err := ioutil.WriteFile(filepath.Join(dir, "x.go"), buf.Bytes(), 0666); err != nil {
56 cmd := exec.Command("go", "tool", "compile", "-p=p", "x.go")
58 output, err := cmd.CombinedOutput()
60 log.Fatal("compile succeeded unexpectedly")
62 if !bytes.Contains(output, []byte("only allowed in runtime")) {
63 log.Fatalf("wrong error message from compiler; got:\n%s\n", output)