https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60875

--- Comment #11 from Alejandro Colomar <[email protected]> ---
Clang supports these pragmas within expressions while GCC doesn't.

It would be nice to have GCC follow Clang here, since that would allow writing
ISO-C-conforming macros that use pragma to disable some diagnostics.

alx@debian:~/tmp$ cat p.c 
int
main(void)
{
        return (
                _Pragma("GCC diagnostic push")
                42
                _Pragma("GCC diagnostic pop")
        );
}
alx@debian:~/tmp$ gcc -Wall -Wextra p.c 
p.c: In function ‘main’:
p.c:5:17: error: expected expression before ‘#pragma’
    5 |                 _Pragma("GCC diagnostic push")
      |                 ^~~~~~~
alx@debian:~/tmp$ clang -Weverything p.c 
alx@debian:~/tmp$ ./a.out; echo $?
42

Reply via email to