This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [c/c++] PR 36513: add testcase
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 16 Feb 2010 21:10:05 +0100
- Subject: Re: [c/c++] PR 36513: add testcase
- References: <6c33472e1002161158m7368e518r710045ea9ed891dd@mail.gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Feb 16, 2010 at 08:58:47PM +0100, Manuel López-Ibáñez wrote:
> --- gcc/testsuite/c-c++-common/pr36513.c (revision 0)
> +++ gcc/testsuite/c-c++-common/pr36513.c (revision 0)
> @@ -0,0 +1,21 @@
> +/* PR 36513: -Wlogical-op warns about strchr */
> +/* { dg-do compile } */
> +/* { dg-options "-Wlogical-op" } */
> +
> +extern void *__rawmemchr (const void *__s, int __c);
> +int main1 ()
> +{
> + char *s, t;
> + (__extension__ (__builtin_constant_p (t) && !__builtin_constant_p (s) && (t) == '\0' ? (char *) __rawmemchr (s, t) : __builtin_strchr (s, t)));
> +}
> +
> +#ifdef __cplusplus
> +#include <cstring>
> +#else
> +#include <string.h>
> +#endif
> +int main2 ()
> +{
> + char *s, t;
> + strchr (s, t);
> +}
I think it is wrong to put two testcases into one, would be much better to
split it. One issue is e.g. with __rawmemchr, as you are using target's
string.h, __rawmemchar might very well be defined in string.h, with
different properties from the declared prototype (extern "C" vs. C++,
throw () vs. not throw () etc.).
In main1 you should also fix up formatting, so it doesn't have almost 150
chars on a single line.
Jakub