// will be converted to OCASE
// right will point to next case
// done in casebody()
- markdcl()
+ markdcl() // matching popdcl in caseblock
stmt := Nod(OXCASE, nil, nil)
stmt.List = cases
if tswitch != nil {
// will be converted to OCASE
// right will point to next case
// done in casebody()
- markdcl()
+ markdcl() // matching popdcl in caseblock
stmt := Nod(OXCASE, nil, nil)
var n *Node
if cases.Next == nil {
// will be converted to OCASE
// right will point to next case
// done in casebody()
- markdcl()
+ markdcl() // matching popdcl in caseblock
stmt := Nod(OXCASE, nil, nil)
stmt.List = list1(colas(cases, list1(rhs), int32(p.op)))
return stmt
default:
+ markdcl() // for matching popdcl in caseblock
+ stmt := Nod(OXCASE, nil, nil) // don't return nil
p.syntax_error("expecting := or = or : or comma")
p.advance(LCASE, LDEFAULT, '}')
- return nil
+ return stmt
}
case LDEFAULT:
// LDEFAULT ':'
p.next()
- markdcl()
+ markdcl() // matching popdcl in caseblock
stmt := Nod(OXCASE, nil, nil)
if tswitch != nil {
if n := tswitch.Left; n != nil {
return stmt
default:
+ markdcl() // matching popdcl in caseblock
+ stmt := Nod(OXCASE, nil, nil) // don't return nil
p.syntax_error("expecting case or default or }")
p.advance(LCASE, LDEFAULT, '}')
- return nil
+ return stmt
}
}
defer p.trace("caseblock")()
}
- stmt := p.case_(tswitch)
+ stmt := p.case_(tswitch) // does markdcl
// If the last token read by the lexer was consumed
// as part of the case, clear it (parser has cleared yychar).
stmt.Nbody = p.loop_body("if clause")
- l := p.elseif_list_else()
+ l := p.elseif_list_else() // does markdcl
n := stmt
popdcl()
}
// LELSE LIF already consumed
- markdcl()
+ markdcl() // matching popdcl in if_stmt
stmt := p.if_header()
if stmt.Left == nil {
--- /dev/null
+// errorcheck
+
+// Copyright 2015 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.
+
+// Check various syntax errors with switches.
+
+package main
+
+func _() {
+ switch {
+ case 0; // ERROR "expecting := or = or : or comma"
+ }
+
+ switch {
+ case 0; // ERROR "expecting := or = or : or comma"
+ default:
+ }
+
+ switch {
+ if x: // ERROR "expecting case or default or }"
+ }
+}