--- /dev/null
+// Copyright 2019 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.
+
+// Error with newline inserted into constant expression.
+// Compilation test only, nothing to run.
+
+package cgotest
+
+// static void issue29781F(char **p, int n) {}
+// #define ISSUE29781C 0
+import "C"
+
+func issue29781G() {
+ var p *C.char
+ C.issue29781F(&p, C.ISSUE29781C+1)
+}
// AST expression onto a single line. The lexer normally inserts a
// semicolon at each newline, so we can replace newline with semicolon.
// However, we can't do that in cases where the lexer would not insert
-// a semicolon. Fortunately we only have to worry about cases that
-// can occur in an expression passed through gofmt, which just means
-// composite literals.
+// a semicolon. We only have to worry about cases that can occur in an
+// expression passed through gofmt, which means composite literals and
+// (due to the printer possibly inserting newlines because of position
+// information) operators.
var gofmtLineReplacer = strings.NewReplacer(
"{\n", "{",
",\n", ",",
+ "++\n", "++;",
+ "--\n", "--;",
+ "+\n", "+",
+ "-\n", "-",
+ "*\n", "*",
+ "/\n", "/",
+ "%\n", "%",
+ "&\n", "&",
+ "|\n", "|",
+ "^\n", "^",
+ "<\n", "<",
+ ">\n", ">",
+ "=\n", "=",
+ ",\n", ",",
"\n", ";",
)