Skip to content

cmd/vet: asmdecl flag scans code in multiline comments #58866

Description

@WojciechMula

What version of Go are you using (go version)?

$ go version
go version go1.20 linux/amd64

What did you do?

This is the repro:

~/tmp/govet$ cat go.mod 
module main

~/tmp/govet$ cat main.go 
package main

// go:noescape
// go:nosplit
func procedure()

func main() {
    procedure()
}

~/tmp/govet$ cat proc_amd64.s 
#include "textflag.h"
#include "funcdata.h"
#include "go_asm.h"

TEXT ·procedure(SB), NOSPLIT|NOFRAME, $0-0
    /*
        Commented out garbage

        MOVQ    nonexistingprocedureargument+42(FP), ZMM1
    */
    RET

# this compiles correctly
~/tmp/govet$ go build; echo $?
0

# vet complains
~/tmp/govet$ go vet -asmdecl
# main
./proc_amd64.s:9:1: [amd64] procedure: unknown variable nonexistingprocedureargument

When line 9 is commented with // then go vet does not complain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AnalysisIssues related to static analysis (vet, x/tools/go/analysis)NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions