https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127044
Bug ID: 127044
Summary: Warning for __attribute__((assume(statement))) when
-Wdeclaration-after-statement used
Product: gcc
Version: 16.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: k2k at drgrin dot dev
Target Milestone: ---
A warning produced every time when __attribute__((assume(statement))) used
after the code and compiled with -Wdeclaration-after-statement or -std=c89
-pedantic.
A minimal example:
$ cat > test.c << _EOF_
int f(void)
{
int r;
r = 1;
__attribute__((assume(r > 0)));
return r;
}
_EOF_
$ gcc -c test.c -Wdeclaration-after-statement
test.c: In function 'f':
test.c:5:3: warning: ISO C90 forbids mixed declarations and code
[-Wdeclaration-after-statement]
5 | __attribute__((assume(r > 0)));
| ^~~~~~~~~~~~~
$ gcc -c test.c -std=c89 -pedantic
test.c: In function 'f':
test.c:5:3: warning: ISO C90 forbids mixed declarations and code
[-Wdeclaration-after-statement]
5 | __attribute__((assume(r > 0)));
| ^~~~~~~~~~~~~
The same for:
$ gcc-14 --version
gcc-14 (Gentoo 14.3.1_p20260604 p6) 14.3.1 20260604
$ gcc --version
gcc (Gentoo 15.3.0 p8) 15.3.0
$ gcc-16 --version
gcc-16 (Gentoo 16.2.0 p3) 16.2.0