elliotchance / c2go

⚖️ A tool for transpiling C to Go.
MIT License
2.09k stars 155 forks source link

panic: unknown node type: BuiltinAttr #880

Closed ishuah closed 3 years ago

ishuah commented 3 years ago

clang -v

Ubuntu clang version 11.1.0-++20210203115409+1fdec59bffc1-1~exp1~20210203230038.161
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

go version : go version go1.13.4 linux/amd64 c2go -v : v0.26.0 Erbium 2020-03-17 OS : Ubuntu 18.04.5 LTS

I tried transpiling the demo prime.c file.

#include <stdio.h>

int main()
{
    int n, c;

    printf("Enter a number\n");
    scanf("%d", &n);
    printf("The number is: %d\n", n);

    if (n == 2)
        printf("Prime number.\n");
    else
    {
        for (c = 2; c <= n - 1; c++)
        {
            if (n % c == 0)
                break;
        }
        if (c != n)
            printf("Not prime.\n");
        else
            printf("Prime number.\n");
    }
    return 0;
}

Result

$ c2go transpile prime.c
panic: unknown node type: 'BuiltinAttr 0x112da38 <<invalid sloc>> Inherited Implicit 748'

goroutine 22 [running]:
github.com/elliotchance/c2go/ast.Parse(0xc0002b150b, 0x3d, 0x6c02f2, 0x5)
    /home/ishuah/go/pkg/mod/github.com/elliotchance/c2go@v0.26.7/ast/ast.go:294 +0x4541
main.convertLinesToNodes(0xc0002ba9f0, 0x3d, 0x131, 0x0, 0x0, 0x0)
    /home/ishuah/go/pkg/mod/github.com/elliotchance/c2go@v0.26.7/main.go:89 +0x1a6
main.convertLinesToNodesParallel.func1.2(0xc00017a5a0, 0xc0001d4068, 0xc0002ba9f0, 0x3d, 0x131, 0x0)
    /home/ishuah/go/pkg/mod/github.com/elliotchance/c2go@v0.26.7/main.go:121 +0x53
created by main.convertLinesToNodesParallel.func1
    /home/ishuah/go/pkg/mod/github.com/elliotchance/c2go@v0.26.7/main.go:119 +0x1b5
ishuah commented 3 years ago

Retracted. Downgrading to clang version 6.0.0 fixed this problem.

rxa1031 commented 4 months ago

Hi, Please help me understand the reason why the issue is observed when using clang version 18.1.6. Regards, Rajeev