This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [c/c++] PR 36513: add testcase


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]