bug testing for fallthrough attribute in ax_gcc_func_attribute.m4

Cheyenne Wills <[email protected]> Fri, 15 May 2020 17:06:23 -0600
Newsgroups gmane.comp.sysutils.autoconf.archive-maintainers
Message-ID <CAHpsFVftu2iZ+koqLF6pK-Mb3+AXK8poWEptUAF-oX-X54e3hg@mail.gmail.com>
--00000000000054370205a5b7dd60
Content-Type: text/plain; charset="UTF-8"

Hello,

Hopefully this is the right email to report a bug.

When testing for the fallthrough attribute with clang-10, the test is
failing with a false negative (e.g. it's failing for a different reason).

Here is the output of a config.log with the warnings that are being
generated by clang-10

configure:31082: checking for __attribute__((fallthrough))
configure:31103: clang-10 -o conftest     conftest.c  >&5
conftest.c:232:46: warning: no case matching constant switch condition '0'
                    int foo( void ) {switch (0) { case 1:
__attribute__((fallthrough)); case 2: break ; }};
                                             ^
conftest.c:232:106: warning: non-void function does not return a value
[-Wreturn-type]
                    int foo( void ) {switch (0) { case 1:
__attribute__((fallthrough)); case 2: break ; }};

                             ^
2 warnings generated.
configure:31103: $? = 0
configure:31116: result: no

Looking at the ax_gcc_func_attribute.m4 file, the C code for the test is:

    int foo( void ) {switch (0) { case 1: __attribute__((fallthrough));
case 2: break ; }};

I tested the following and this looks like it might be a possible fix:

    void foo(int x) { switch(x) { case 1:__attribute__((fallthrough)); case
2: break ; }};


Cheyenne Wills
[email protected]

--00000000000054370205a5b7dd60
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello,=C2=A0<div><br></div><div>Hopefully this is the righ=
t email to report a bug.</div><div><br></div><div>When testing for the fall=
through attribute with clang-10, the test is failing with a false negative =
(e.g. it&#39;s failing for a different reason).<br><br>Here is the output o=
f a config.log with the warnings that are being generated by clang-10</div>=
<div><br></div><div><font face=3D"monospace">configure:31082: checking for =
__attribute__((fallthrough))<br>configure:31103: clang-10 -o conftest =C2=
=A0 =C2=A0 conftest.c =C2=A0&gt;&amp;5<br>conftest.c:232:46: warning: no ca=
se matching constant switch condition &#39;0&#39;<br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 int foo( void ) {switch (0=
) { case 1: __attribute__((fallthrough)); case 2: break ; }};<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0^<br>conftest.c:232:106: warning: non-void function does not return a va=
lue [-Wreturn-type]<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 int foo( void ) {switch (0) { case 1: __attribute__((fall=
through)); case 2: break ; }};<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^<br>2 warnings generated.<br>configure:3=
1103: $? =3D 0<br>configure:31116: result: no</font><br></div><div><font fa=
ce=3D"monospace"><br></font></div><div><font face=3D"arial, sans-serif">Loo=
king at the ax_gcc_func_attribute.m4 file, the C code for the test is:</fon=
t></div><div><br></div><div>=C2=A0 =C2=A0 int foo( void ) {switch (0) { cas=
e 1: __attribute__((fallthrough)); case 2: break ; }};<br></div><div><br></=
div><div>I tested the following and this looks like it might be a possible =
fix:</div><div><br></div><div>=C2=A0 =C2=A0 void foo(int x) { switch(x) { c=
ase 1:__attribute__((fallthrough)); case 2: break ; }};</div><br><div><br><=
/div><div>Cheyenne Wills</div><div><a href=3D"mailto:[email protected]=
om">[email protected]</a></div></div>

--00000000000054370205a5b7dd60--