diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
commit | 1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch) | |
tree | c607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c | |
parent | 283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff) | |
download | toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2 toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip |
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c')
-rw-r--r-- | gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c new file mode 100644 index 000000000..7046aad65 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c @@ -0,0 +1,107 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that built-in ctype transformations are done correctly by + the compiler. + + Written by Kaveh Ghazi, 2004-04-05. */ + +/* { dg-do link } */ + +extern void link_failure_var(void); + +void test(int i) +{ + /* All of these ctype calls should compile-time evaluate to true. */ +#define TEST_CTYPE_CST_TRUE(FN, VALUE) \ + extern void link_failure_##FN##_cst_true(void); \ + extern int FN(int); \ + if (! FN(VALUE)) \ + link_failure_##FN##_cst_true() + + /* All of these ctype calls should compile-time evaluate to false. */ +#define TEST_CTYPE_CST_FALSE(FN, VALUE) \ + extern void link_failure_##FN##_cst_false(void); \ + extern int FN(int); \ + if (FN(VALUE)) \ + link_failure_##FN##_cst_false() + + /* All of these ctype calls should compile-time evaluate to true. */ +#define TEST_TOCTYPE_CST_TRUE(FN, VALUE) \ + extern void link_failure_##FN##_cst_true(void); \ + extern int FN(int); \ + if (FN(VALUE) != (VALUE)) \ + link_failure_##FN##_cst_true() + + /* All of these ctype calls should compile-time evaluate to false. */ +#define TEST_TOCTYPE_CST_FALSE(FN, VALUE) \ + extern void link_failure_##FN##_cst_false(void); \ + extern int FN(int); \ + if (FN(VALUE) == (VALUE)) \ + link_failure_##FN##_cst_false() + +#ifdef __OPTIMIZE__ + TEST_CTYPE_CST_TRUE (isascii, 0); + TEST_CTYPE_CST_TRUE (isascii, 1); + TEST_CTYPE_CST_TRUE (isascii, 126); + TEST_CTYPE_CST_TRUE (isascii, 127); + + TEST_CTYPE_CST_FALSE (isascii, -1); + TEST_CTYPE_CST_FALSE (isascii, 128); + TEST_CTYPE_CST_FALSE (isascii, 129); + TEST_CTYPE_CST_FALSE (isascii, 255); + TEST_CTYPE_CST_FALSE (isascii, 256); + TEST_CTYPE_CST_FALSE (isascii, 257); + TEST_CTYPE_CST_FALSE (isascii, 10000); + TEST_CTYPE_CST_FALSE (isascii, __INT_MAX__); + + /* This ctype call should transform into another expression. */ + if (isascii(i) != ((i & ~0x7f) == 0)) + link_failure_var(); + + TEST_TOCTYPE_CST_TRUE (toascii, 0); + TEST_TOCTYPE_CST_TRUE (toascii, 1); + TEST_TOCTYPE_CST_TRUE (toascii, 126); + TEST_TOCTYPE_CST_TRUE (toascii, 127); + + TEST_TOCTYPE_CST_FALSE (toascii, -1); + TEST_TOCTYPE_CST_FALSE (toascii, 128); + TEST_TOCTYPE_CST_FALSE (toascii, 129); + TEST_TOCTYPE_CST_FALSE (toascii, 255); + TEST_TOCTYPE_CST_FALSE (toascii, 256); + TEST_TOCTYPE_CST_FALSE (toascii, 10000); + TEST_TOCTYPE_CST_FALSE (toascii, __INT_MAX__); + + /* This ctype call should transform into another expression. */ + if (toascii(i) != (i & 0x7f)) + link_failure_var(); + + TEST_CTYPE_CST_TRUE (isdigit, '0'); + TEST_CTYPE_CST_TRUE (isdigit, '1'); + TEST_CTYPE_CST_TRUE (isdigit, '2'); + TEST_CTYPE_CST_TRUE (isdigit, '3'); + TEST_CTYPE_CST_TRUE (isdigit, '4'); + TEST_CTYPE_CST_TRUE (isdigit, '5'); + TEST_CTYPE_CST_TRUE (isdigit, '6'); + TEST_CTYPE_CST_TRUE (isdigit, '7'); + TEST_CTYPE_CST_TRUE (isdigit, '8'); + TEST_CTYPE_CST_TRUE (isdigit, '9'); + + TEST_CTYPE_CST_FALSE (isdigit, '0'-1); + TEST_CTYPE_CST_FALSE (isdigit, '9'+1); + TEST_CTYPE_CST_FALSE (isdigit, -1); + TEST_CTYPE_CST_FALSE (isdigit, 0); + TEST_CTYPE_CST_FALSE (isdigit, 255); + TEST_CTYPE_CST_FALSE (isdigit, 256); + TEST_CTYPE_CST_FALSE (isdigit, 10000); + TEST_CTYPE_CST_FALSE (isdigit, __INT_MAX__); + + /* This ctype call should transform into another expression. */ + if (isdigit(i) != ((unsigned)i - '0' <= 9)) + link_failure_var(); +#endif /* __OPTIMIZE__ */ +} + +int main (void) +{ + return 0; +} |