OSDN Git Service

PR c++/14971
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.c-torture / execute / builtins / string-6.c
1 /* Copyright (C) 2001  Free Software Foundation.
2
3    Ensure that builtin memcmp operations when all three arguments
4    are constant is optimized and performs correctly.  Taken from
5    PR optimize/3508.
6
7    Written by Roger Sayle, 12/26/2001.  */
8
9 extern void abort (void);
10 extern void link_error (void);
11
12 typedef __SIZE_TYPE__ size_t;
13 extern int memcmp (const void *, const void *, size_t);
14
15 void
16 main_test (void)
17 {
18   if (memcmp ("abcd", "efgh", 4) >= 0)
19     link_error ();
20   if (memcmp ("abcd", "abcd", 4) != 0)
21     link_error ();
22   if (memcmp ("efgh", "abcd", 4) <= 0)
23     link_error ();
24 }
25
26 #ifndef __OPTIMIZE__
27 /* When not optimizing, the above tests may generate references to
28    the function link_error, but should never actually call it.  */
29 void
30 link_error ()
31 {
32   abort ();
33 }
34 #endif