ltcmelo / psychec

A compiler frontend for the C programming language
BSD 3-Clause "New" or "Revised" License
538 stars 39 forks source link

`__attribute__` keyword unaccepted (needs `-Wno-unused-variable`) #15

Closed aytey closed 2 years ago

aytey commented 3 years ago

If eligible for the bounty, I wish this to be donated to a local animal charity of the maintainer's choice

GCC version:

gcc (SUSE Linux) 10.2.1 20201202 [revision e563687cf9d3d1278f45aaebd03e0f66531076c9]

clang version:

clang version 11.0.1

Output of gcc -Werror -Wall -Wextra -Wpedantic -Wno-unused-variable -pedantic -std=c11 -c $FNAME

(return code 0)

Output of clang -Werror -Wall -Wextra -Wpedantic -Wno-unused-variable -pedantic -std=c11 -c $FNAME

(return code 0)

Output of cnip $FNAME

vector-2.c:3:2 error: expected expression got `__attribute__'
  __attribute__((vector_size(16))) float t1;
  ^

(return code 0)

Content of file

void getCapsule() {
  __attribute__((vector_size(16))) float t1;
}

psychec version

commit 6d7b8249e0f28af105112b217cb33a24f666e148
Author: Leandro T. C. Melo <LTCMELO@GMAIL.COM>
Date:   Tue Feb 23 07:47:25 2021 -0300

    link expression-parsing table in Doxygen documentation
aytey commented 3 years ago

GCC version:

gcc (SUSE Linux) 10.2.1 20201202 [revision e563687cf9d3d1278f45aaebd03e0f66531076c9]

clang version:

clang version 11.0.1

Output of gcc -Werror -Wall -Wextra -Wpedantic -pedantic -std=c11 -c $FNAME

(return code 0)

Output of clang -Werror -Wall -Wextra -Wpedantic -pedantic -std=c11 -c $FNAME

(return code 0)

Output of cnip $FNAME

attributes.c:1:1 warning: missing type specifier, assume `int'

 ^
attributes.c:2:40 error: expected `,' or `;' or `=' after declarator, got `foo'
u32 __attribute__ ((noinline, nothrow))
                                        ^
attributes.c:5:14 warning: missing type specifier, assume `int'
    return 0;
              ^
attributes.c:5:14 error: expected <identifier> or `(' starting direct-declarator, got `}'
    return 0;
              ^

(return code 0)

Content of file

typedef int u32;

u32 __attribute__ ((noinline, nothrow))
foo (void)
{
    return 0;
}

psychec version

commit d10dc1ddfb7ea845f59274a4d6ca5d021ab31423
Author: Leandro T. C. Melo <LTCMELO@GMAIL.COM>
Date:   Tue Mar 9 21:18:30 2021 -0300

    fix postfixing on compound literal
aytey commented 3 years ago

GCC version:

gcc (SUSE Linux) 10.2.1 20201202 [revision e563687cf9d3d1278f45aaebd03e0f66531076c9]

clang version:

clang version 11.0.1

Output of gcc -Werror -Wall -Wextra -Wpedantic -pedantic -std=c11 -c $FNAME

(return code 0)

Output of clang -Werror -Wall -Wextra -Wpedantic -pedantic -std=c11 -c $FNAME

(return code 0)

Output of cnip $FNAME

attributes.c:0:17 warning: missing type specifier, assume `int'
typedef int u32;
                 ^
attributes.c:1:22 error: expected `,' or `;' or `=' after declarator, got `foo0'
u32 __attribute__(()) foo0;
                      ^

(return code 0)

Content of file

typedef int u32;
u32 __attribute__(()) foo0;

psychec version

commit d10dc1ddfb7ea845f59274a4d6ca5d021ab31423
Author: Leandro T. C. Melo <LTCMELO@GMAIL.COM>
Date:   Tue Mar 9 21:18:30 2021 -0300

    fix postfixing on compound literal
ltcmelo commented 2 years ago

Fixed with 2852ad5e1f0f5556d969a6a3b8f5ac7086568882