Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Go
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Stiemerling
Go
Commits
52943bfe
Commit
52943bfe
authored
14 years ago
by
Russ Cox
Browse files
Options
Downloads
Patches
Plain Diff
gc: require if condition
R=ken2, r2 CC=golang-dev
https://golang.org/cl/4195045
parent
814075df
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cmd/gc/go.y
+7
-2
7 additions, 2 deletions
src/cmd/gc/go.y
test/syntax/if.go
+15
-0
15 additions, 0 deletions
test/syntax/if.go
with
22 additions
and
2 deletions
src/cmd/gc/go.y
+
7
−
2
View file @
52943bfe
...
...
@@ -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
}
...
...
This diff is collapsed.
Click to expand it.
test/syntax/if.go
0 → 100644
+
15
−
0
View file @
52943bfe
// 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"
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment