Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParmVarDecl could not match regexp #280

Closed
yulvil opened this issue Oct 26, 2017 · 2 comments
Closed

ParmVarDecl could not match regexp #280

yulvil opened this issue Oct 26, 2017 · 2 comments

Comments

@yulvil
Copy link
Contributor

yulvil commented Oct 26, 2017

main.c

long test(char foo[42]) {
    return sizeof(foo);
}

int main() {
    char abc[1];
    return test(abc);
}

c2go transpile main.c

panic: could not match regexp '<(?P<position>.*)>
                (?P<position2> [^ ]+:[\d:]+)?
                (?P<used> used)?
                (?P<name> \w+)?
                 '(?P<type>.*?)'
                (?P<type2>:'.*?')?' with string 'ParmVarDecl 0x55b17f101780 <col:11, col:22> col:16 referenced foo 'char *':'char *''

cc -Wall -o main main.c

main.c: In function ‘test’:
main.c:3:16: warning: ‘sizeof’ on array function parameter ‘foo’ will return size of ‘char *’ [-Wsizeof-array-argument]
   return sizeof(foo) - sizeof(bar);
                ^
main.c:1:16: note: declared here
 long test(char foo[42]) {
                ^~~
@elliotchance
Copy link
Owner

To fix this you will need to add a new test case to: https://github.com/elliotchance/c2go/blob/master/ast/parm_var_decl_test.go#L69-L78 using the string:

0x55b17f101780 <col:11, col:22> col:16 referenced foo 'char *':'char *'

You ill then need to alter the regex to match the new string.

@yulvil
Copy link
Contributor Author

yulvil commented Oct 28, 2017

After the fix, the go output is:

package main

import "os"

type __int128_t int64
type __uint128_t uint64

func test(foo []byte) int32 {
        return int32(8)
}
func main() {
        __init()
        var abc []byte = make([]byte, 1, 1)
        os.Exit(int(test(abc)))
}
func __init() {
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants