aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2021-04-14 16:18:58 -0700
committerKeith Randall <khr@golang.org>2021-04-15 00:29:05 +0000
commit083a26c7d2faa8194782856c6f4efce47703df01 (patch)
tree505c96e5b14ea2ecfbd5de7300b62c18f0a4865f /test
parentbf634c76b28a4a857c9d2a039c53982ffbdcceb7 (diff)
downloadgo-083a26c7d2faa8194782856c6f4efce47703df01.tar.gz
go-083a26c7d2faa8194782856c6f4efce47703df01.zip
cmd/compile: propagate pragmas from generic function to stenciled implementation
Change-Id: I28a1910890659aaa449ffd2a847cd4ced5a8600d Reviewed-on: https://go-review.googlesource.com/c/go/+/310211 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/typeparam/pragma.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/typeparam/pragma.go b/test/typeparam/pragma.go
new file mode 100644
index 0000000000..6743e24ff3
--- /dev/null
+++ b/test/typeparam/pragma.go
@@ -0,0 +1,19 @@
+// errorcheck -0 -m -G=3
+
+// Copyright 2021 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.
+
+// Make sure the go:noinline pragma makes it from a
+// generic function to any of its stenciled instances.
+
+package main
+
+//go:noinline
+func f[T any](x T) T {
+ return x
+}
+
+func main() { // ERROR "can inline main"
+ println(f(5))
+}