1
0
mirror of https://github.com/golang/go synced 2024-11-21 14:54:40 -07:00

gc: require if condition

R=ken2, r2
CC=golang-dev
https://golang.org/cl/4195045
This commit is contained in:
Russ Cox 2011-02-22 18:23:29 -05:00
parent 814075dffb
commit 52943bfe4d
2 changed files with 22 additions and 2 deletions

View File

@ -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
View 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"
}
}