--- /dev/null
+// Copyright 2018 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.
+
+// cgo's /*line*/ comments failed when inserted after '/',
+// because the result looked like a "//" comment.
+// No runtime test; just make sure it compiles.
+
+package cgotest
+
+// #include <stddef.h>
+import "C"
+
+func Issue29383(n, size uint) int {
+ if ^C.size_t(0)/C.size_t(n) < C.size_t(size) {
+ return 0
+ }
+ return 0
+}
// Record source-level edit for cgo output.
if !r.Done {
- repl := gofmtPos(expr, old.Pos())
+ // Prepend a space in case the earlier code ends
+ // with '/', which would give us a "//" comment.
+ repl := " " + gofmtPos(expr, old.Pos())
end := fset.Position(old.End())
// Subtract 1 from the column if we are going to
// append a close parenthesis. That will set the
sub = 1
}
if end.Column > sub {
- repl = fmt.Sprintf("%s/*line :%d:%d*/", repl, end.Line, end.Column-sub)
+ repl = fmt.Sprintf("%s /*line :%d:%d*/", repl, end.Line, end.Column-sub)
}
if r.Name.Kind != "type" {
repl = "(" + repl + ")"