return n
bad:
- if n.Diag == 0 {
+ if !n.Diag {
if !t.Broke {
yyerror("cannot convert %v to type %v", n, t)
}
- n.Diag = 1
+ n.Diag = true
}
if n.Type.IsUntyped() {
switch uint32(n.Op)<<16 | uint32(v.Ctype()) {
default:
- if n.Diag == 0 {
+ if !n.Diag {
yyerror("illegal constant expression %v %v", n.Op, nl.Type)
- n.Diag = 1
+ n.Diag = true
}
return
// The default case above would print 'ideal % ideal',
// which is not quite an ideal error.
case OMOD_ | CTFLT_:
- if n.Diag == 0 {
+ if !n.Diag {
yyerror("illegal constant expression: floating-point %% operation")
- n.Diag = 1
+ n.Diag = true
}
return
return
illegal:
- if n.Diag == 0 {
+ if !n.Diag {
yyerror("illegal constant expression: %v %v %v", nl.Type, n.Op, nr.Type)
- n.Diag = 1
+ n.Diag = true
}
}
if n.Val().Ctype() == CTNIL {
lineno = lno
- if n.Diag == 0 {
+ if !n.Diag {
yyerror("use of untyped nil")
- n.Diag = 1
+ n.Diag = true
}
n.Type = nil
Class Class // PPARAM, PAUTO, PEXTERN, etc
Embedded uint8 // ODCLFIELD embedded type
Colas bool // OAS resulting from :=
- Diag uint8 // already printed error about this
+ Diag bool // already printed error about this
Noescape bool // func arguments do not escape; TODO(rsc): move Noescape to Func struct (see CL 7360)
Walkdef uint8 // tracks state during typecheckdef; 2 == loop detected
Typecheck uint8 // tracks state during typechecking; 2 == loop detected
t = typSlice(r.Type)
} else if n.Left.Op == ODDD {
if top&Ecomplit == 0 {
- if n.Diag == 0 {
- n.Diag = 1
+ if !n.Diag {
+ n.Diag = true
yyerror("use of [...] array outside of array literal")
}
n.Type = nil
// call and call like
case OCALL:
n.Left = typecheck(n.Left, Erv|Etype|Ecall)
- n.Diag |= n.Left.Diag
+ if n.Left.Diag {
+ n.Diag = true
+ }
+
l := n.Left
if l.Op == ONAME && l.Etype != 0 {
if !l.Type.Broke {
yyerror("invalid use of ... in type conversion to %v", l.Type)
}
- n.Diag = 1
+ n.Diag = true
}
// pick off before type-checking arguments
var why string
n.Op = convertop(t, n.Type, &why)
if n.Op == 0 {
- if n.Diag == 0 && !n.Type.Broke {
+ if !n.Diag && !n.Type.Broke {
yyerror("cannot convert %L to type %v%s", n.Left, n.Type, why)
- n.Diag = 1
+ n.Diag = true
}
n.Op = OCONV
case ODEFER:
ok |= Etop
n.Left = typecheck(n.Left, Etop|Erv)
- if n.Left.Diag == 0 {
+ if !n.Left.Diag {
checkdefergo(n)
}
break OpSwitch
}
if (top&Etop != 0) && top&(Ecall|Erv|Etype) == 0 && ok&Etop == 0 {
- if n.Diag == 0 {
+ if !n.Diag {
yyerror("%v evaluated but not used", n)
- n.Diag = 1
+ n.Diag = true
}
n.Type = nil
return
}
- if n.Diag == 0 {
+ if !n.Diag {
// The syntax made sure it was a call, so this must be
// a conversion.
- n.Diag = 1
-
+ n.Diag = true
yyerror("%s requires function call, not conversion", what)
}
}
return
notenough:
- if n == nil || n.Diag == 0 {
+ if n == nil || !n.Diag {
if call != nil {
// call is the expression being called, not the overall call.
// Method expressions have the form T.M, and the compiler has
yyerror("not enough arguments to %v\n\thave %s\n\twant %v", op, nl.retsigerr(isddd), tstruct)
}
if n != nil {
- n.Diag = 1
+ n.Diag = true
}
}
l.Left = typecheck(l.Left, Erv)
evconst(l.Left)
i = nonnegintconst(l.Left)
- if i < 0 && l.Left.Diag == 0 {
+ if i < 0 && !l.Left.Diag {
yyerror("index must be non-negative integer constant")
- l.Left.Diag = 1
+ l.Left.Diag = true
i = -(1 << 30) // stay negative for a while
}
vp = &l.Right
n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, Etype)
t := n.Name.Param.Ntype.Type
if t == nil {
- n.Diag = 1
+ n.Diag = true
n.Type = nil
goto ret
}
if n.Type == nil {
- n.Diag = 1
+ n.Diag = true
goto ret
}
setlineno(n)
if n.Op == ONONAME {
- if n.Diag == 0 {
- n.Diag = 1
+ if !n.Diag {
+ n.Diag = true
if n.Lineno != 0 {
lineno = n.Lineno
}
n.Type = n.Name.Param.Ntype.Type
n.Name.Param.Ntype = nil
if n.Type == nil {
- n.Diag = 1
+ n.Diag = true
goto ret
}
}
}
if e.Type != nil && e.Op != OLITERAL || !isgoconst(e) {
- if e.Diag == 0 {
+ if !e.Diag {
yyerror("const initializer %v is not a constant", e)
- e.Diag = 1
+ e.Diag = true
}
goto ret
n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, Etype)
n.Type = n.Name.Param.Ntype.Type
if n.Type == nil {
- n.Diag = 1
+ n.Diag = true
goto ret
}
}