Source file src/cmd/cgo/internal/testplugin/testdata/mangle/plugin.go

     1  // Copyright 2023 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Test cases for symbol name mangling.
     6  
     7  package main
     8  
     9  import (
    10  	"fmt"
    11  	"strings"
    12  )
    13  
    14  // Issue 58800:
    15  // Instantiated function name may contain weird characters
    16  // that confuse the external linker, so it needs to be
    17  // mangled.
    18  type S struct {
    19  	X int `parser:"|@@)"`
    20  }
    21  
    22  //go:noinline
    23  func F[T any]() {}
    24  
    25  func P() {
    26  	F[S]()
    27  }
    28  
    29  // Issue 62098: the name mangling code doesn't handle some string
    30  // symbols correctly.
    31  func G(id string) error {
    32  	if strings.ContainsAny(id, "&$@;/:+,?\\{^}%`]\">[~<#|") {
    33  		return fmt.Errorf("invalid")
    34  	}
    35  	return nil
    36  }
    37  
    38  func main() {}
    39  

View as plain text