4 // Copyright 2015 The Go Authors. All rights reserved.
5 // Use of this source code is governed by a BSD-style
6 // license that can be found in the LICENSE file.
8 // Issue 11771: Magic comments should ignore carriage returns.
24 if runtime.Compiler != "gc" {
28 dir, err := ioutil.TempDir("", "go-issue11771")
30 log.Fatalf("creating temp dir: %v\n", err)
32 defer os.RemoveAll(dir)
34 // The go:nowritebarrier magic comment is only permitted in
35 // the runtime package. So we confirm that the compilation
45 fmt.Fprintln(&buf, "//go:nowritebarrier\r")
51 if err := ioutil.WriteFile(filepath.Join(dir, "x.go"), buf.Bytes(), 0666); err != nil {
55 cmd := exec.Command("go", "tool", "compile", "x.go")
57 output, err := cmd.CombinedOutput()
59 log.Fatal("compile succeeded unexpectedly")
61 if !bytes.Contains(output, []byte("only allowed in runtime")) {
62 log.Fatalf("wrong error message from compiler; got:\n%s\n", output)