x = ir.Copy(x)
ir.EditChildrenWithHidden(x, edit)
if x, ok := x.(*ir.ConvExpr); ok && x.X.Op() == ir.OLITERAL {
- // A conversion of variable or expression involving variables
- // may become a conversion of constant after inlining the parameters
- // and doing constant evaluation. Truncations that were valid
- // on variables are not valid on constants, so we might have
- // generated invalid code that will trip up the rest of the compiler.
- // Fix those by truncating the constants.
- if x, ok := truncate(x.X.(*ir.ConstExpr), x.Type()); ok {
+ if x, ok := truncate(x.X, x.Type()); ok {
return x
}
valid = false
// truncate returns the result of force converting c to type t,
// truncating its value as needed, like a conversion of a variable.
// If the conversion is too difficult, truncate returns nil, false.
-func truncate(c *ir.ConstExpr, t *types.Type) (*ir.ConstExpr, bool) {
+func truncate(c ir.Node, t *types.Type) (ir.Node, bool) {
ct := c.Type()
cv := c.Val()
if ct.Kind() != t.Kind() {
}
}
}
- c = ir.NewConstExpr(cv, c).(*ir.ConstExpr)
+ c = ir.NewConstExpr(cv, c)
c.SetType(t)
return c, true
}
--- /dev/null
+// Copyright 2023 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.
+
+package a
+
+func Assert(msgAndArgs ...any) {
+}
+
+func Run() int {
+ Assert("%v")
+ return 0
+}
+
+func Run2() int {
+ return Run()
+}