mirror of
https://github.com/golang/go
synced 2024-11-11 19:51:37 -07:00
gc: require if condition
R=ken2, r2 CC=golang-dev https://golang.org/cl/4195045
This commit is contained in:
parent
814075dffb
commit
52943bfe4d
@ -640,10 +640,15 @@ if_stmt:
|
||||
{
|
||||
markdcl();
|
||||
}
|
||||
if_header loop_body
|
||||
if_header
|
||||
{
|
||||
if($3->ntest == N)
|
||||
yyerror("missing condition in if statement");
|
||||
}
|
||||
loop_body
|
||||
{
|
||||
$$ = $3;
|
||||
$$->nbody = $4;
|
||||
$$->nbody = $5;
|
||||
// no popdcl; maybe there's an LELSE
|
||||
}
|
||||
|
||||
|
15
test/syntax/if.go
Normal file
15
test/syntax/if.go
Normal file
@ -0,0 +1,15 @@
|
||||
// errchk $G $D/$F.go
|
||||
|
||||
// Copyright 2011 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 main
|
||||
|
||||
func main() {
|
||||
if { // ERROR "missing condition"
|
||||
}
|
||||
|
||||
if x(); { // ERROR "missing condition"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user