diff options
Diffstat (limited to 'pkg/compiler/check.go')
| -rw-r--r-- | pkg/compiler/check.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pkg/compiler/check.go b/pkg/compiler/check.go index 75857be40..c5fc226d6 100644 --- a/pkg/compiler/check.go +++ b/pkg/compiler/check.go @@ -8,6 +8,7 @@ package compiler import ( "errors" "fmt" + "regexp" "strings" "github.com/google/syzkaller/pkg/ast" @@ -16,6 +17,7 @@ import ( ) func (comp *compiler) typecheck() { + comp.checkComments() comp.checkDirectives() comp.checkNames() comp.checkFields() @@ -34,6 +36,18 @@ func (comp *compiler) check() { comp.checkDupConsts() } +func (comp *compiler) checkComments() { + confusingComment := regexp.MustCompile(`^\s*(include|incdir|define)`) + for _, decl := range comp.desc.Nodes { + switch n := decl.(type) { + case *ast.Comment: + if confusingComment.MatchString(n.Text) { + comp.error(n.Pos, "confusing comment faking a directive (rephrase if it's intentional)") + } + } + } +} + func (comp *compiler) checkDirectives() { includes := make(map[string]bool) incdirs := make(map[string]bool) |
