]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
builtin-types.def (BT_WINT, [...]): New.
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>
Sat, 27 Mar 2004 05:29:40 +0000 (05:29 +0000)
committerKaveh Ghazi <ghazi@gcc.gnu.org>
Sat, 27 Mar 2004 05:29:40 +0000 (05:29 +0000)
* builtin-types.def (BT_WINT, BT_FN_INT_WINT, BT_FN_WINT_WINT): New.
* builtins.def (DEF_C94_BUILTIN): New.  Add wctype builtins.
* doc/extend.texi: Likewise.
testsuite:
* gcc.dg/torture/builtin-wctype-1.c: New test.

From-SVN: r80011

gcc/ChangeLog
gcc/builtin-types.def
gcc/builtins.def
gcc/doc/extend.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/builtin-wctype-1.c [new file with mode: 0644]

index 3589d427d535422c013ae0771c6f75dc6ee9dbd6..156d56b3fbaf54fcd62fa96f8336aedaf1fc910d 100644 (file)
@@ -1,3 +1,9 @@
+2004-03-27  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * builtin-types.def (BT_WINT, BT_FN_INT_WINT, BT_FN_WINT_WINT): New.
+       * builtins.def (DEF_C94_BUILTIN): New.  Add wctype builtins.
+       * doc/extend.texi: Likewise.
+
 2004-03-26  Diego Novillo  <dnovillo@redhat.com>
 
        * c-typeck.c (comptypes): Replace calls to TYPE_DOMAIN
index bf236cf0d23e0da3403847493c4566813caebe90..81fdeb18505847feb67d6a04026a7f53bb715fb8 100644 (file)
@@ -82,6 +82,7 @@ DEF_PRIMITIVE_TYPE (BT_DOUBLE_PTR, double_ptr_type_node)
 DEF_PRIMITIVE_TYPE (BT_LONGDOUBLE_PTR, long_double_ptr_type_node)
 DEF_PRIMITIVE_TYPE (BT_SIZE, size_type_node)
 DEF_PRIMITIVE_TYPE (BT_SSIZE, signed_size_type_node)
+DEF_PRIMITIVE_TYPE (BT_WINT, wint_type_node)
 DEF_PRIMITIVE_TYPE (BT_STRING, string_type_node)
 DEF_PRIMITIVE_TYPE (BT_CONST_STRING, const_string_type_node)
 
@@ -144,6 +145,8 @@ DEF_FUNCTION_TYPE_1 (BT_FN_LONGDOUBLE_CONST_STRING,
                     BT_LONGDOUBLE, BT_CONST_STRING)
 DEF_FUNCTION_TYPE_1 (BT_FN_STRING_CONST_STRING, BT_STRING, BT_CONST_STRING)
 DEF_FUNCTION_TYPE_1 (BT_FN_WORD_PTR, BT_WORD, BT_PTR)
+DEF_FUNCTION_TYPE_1 (BT_FN_INT_WINT, BT_INT, BT_WINT)
+DEF_FUNCTION_TYPE_1 (BT_FN_WINT_WINT, BT_WINT, BT_WINT)
 
 DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTR_INT, BT_VOID, BT_PTR, BT_INT)
 DEF_FUNCTION_TYPE_2 (BT_FN_STRING_STRING_CONST_STRING, 
index 24118ddf58e455d9d4171d82045e093dfe5ca20d..0d2be2c437a82ce0979faa5feed21d4a1dfd4bc5 100644 (file)
@@ -91,6 +91,13 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
   DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE,   \
               true, true, true, ATTRS, false)
 
+/* Like DEF_LIB_BUILTIN, except that the function is only a part of
+   the standard in C94 or above.  */
+#undef DEF_C94_BUILTIN                                 
+#define DEF_C94_BUILTIN(ENUM, NAME, TYPE, ATTRS)       \
+  DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE,   \
+              true, true, !flag_isoc94, ATTRS, TARGET_C99_FUNCTIONS)
+
 /* Like DEF_LIB_BUILTIN, except that the function is only a part of
    the standard in C99 or above.  */
 #undef DEF_C99_BUILTIN                                 
@@ -509,6 +516,22 @@ DEF_EXT_LIB_BUILTIN    (BUILT_IN_TOASCII, "toascii", BT_FN_INT_INT, ATTR_CONST_N
 DEF_LIB_BUILTIN        (BUILT_IN_TOLOWER, "tolower", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
 DEF_LIB_BUILTIN        (BUILT_IN_TOUPPER, "toupper", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
 
+/* Category: wctype builtins.  */
+DEF_C94_BUILTIN        (BUILT_IN_ISWALNUM, "iswalnum", BT_FN_INT_WINT, ATTR_PURE_NOTHROW_LIST)
+DEF_C94_BUILTIN        (BUILT_IN_ISWALPHA, "iswalpha", BT_FN_INT_WINT, ATTR_PURE_NOTHROW_LIST)
+DEF_C99_BUILTIN        (BUILT_IN_ISWBLANK, "iswblank", BT_FN_INT_WINT, ATTR_PURE_NOTHROW_LIST)
+DEF_C94_BUILTIN        (BUILT_IN_ISWCNTRL, "iswcntrl", BT_FN_INT_WINT, ATTR_PURE_NOTHROW_LIST)
+DEF_C94_BUILTIN        (BUILT_IN_ISWDIGIT, "iswdigit", BT_FN_INT_WINT, ATTR_PURE_NOTHROW_LIST)
+DEF_C94_BUILTIN        (BUILT_IN_ISWGRAPH, "iswgraph", BT_FN_INT_WINT, ATTR_PURE_NOTHROW_LIST)
+DEF_C94_BUILTIN        (BUILT_IN_ISWLOWER, "iswlower", BT_FN_INT_WINT, ATTR_PURE_NOTHROW_LIST)
+DEF_C94_BUILTIN        (BUILT_IN_ISWPRINT, "iswprint", BT_FN_INT_WINT, ATTR_PURE_NOTHROW_LIST)
+DEF_C94_BUILTIN        (BUILT_IN_ISWPUNCT, "iswpunct", BT_FN_INT_WINT, ATTR_PURE_NOTHROW_LIST)
+DEF_C94_BUILTIN        (BUILT_IN_ISWSPACE, "iswspace", BT_FN_INT_WINT, ATTR_PURE_NOTHROW_LIST)
+DEF_C94_BUILTIN        (BUILT_IN_ISWUPPER, "iswupper", BT_FN_INT_WINT, ATTR_PURE_NOTHROW_LIST)
+DEF_C94_BUILTIN        (BUILT_IN_ISWXDIGIT, "iswxdigit", BT_FN_INT_WINT, ATTR_PURE_NOTHROW_LIST)
+DEF_C94_BUILTIN        (BUILT_IN_TOWLOWER, "towlower", BT_FN_WINT_WINT, ATTR_PURE_NOTHROW_LIST)
+DEF_C94_BUILTIN        (BUILT_IN_TOWUPPER, "towupper", BT_FN_WINT_WINT, ATTR_PURE_NOTHROW_LIST)
+
 /* Category: miscellaneous builtins.  */
 DEF_LIB_BUILTIN        (BUILT_IN_ABORT, "abort", BT_FN_VOID, ATTR_NORETURN_NOTHROW_LIST)
 DEF_LIB_BUILTIN        (BUILT_IN_ABS, "abs", BT_FN_INT_INT, ATTR_CONST_NOTHROW_LIST)
index 9eb3b7c44b1665395da83f8fa101bf10e1d5aef8..c5509a8073fefc49f1875cfdc0f4ee7923aedc6b 100644 (file)
@@ -4898,6 +4898,18 @@ v4si f (v4si a, v4si b, v4si c)
 @findex ispunct
 @findex isspace
 @findex isupper
+@findex iswalnum
+@findex iswalpha
+@findex iswblank
+@findex iswcntrl
+@findex iswdigit
+@findex iswgraph
+@findex iswlower
+@findex iswprint
+@findex iswpunct
+@findex iswspace
+@findex iswupper
+@findex iswxdigit
 @findex isxdigit
 @findex j0
 @findex j0f
@@ -5042,6 +5054,8 @@ v4si f (v4si a, v4si b, v4si c)
 @findex toascii
 @findex tolower
 @findex toupper
+@findex towlower
+@findex towupper
 @findex trunc
 @findex truncf
 @findex truncl
@@ -5127,13 +5141,13 @@ The ISO C99 functions
 @code{fmaxf}, @code{fmaxl}, @code{fmax}, @code{fma}, @code{fminf},
 @code{fminl}, @code{fmin}, @code{hypotf}, @code{hypotl}, @code{hypot},
 @code{ilogbf}, @code{ilogbl}, @code{ilogb}, @code{imaxabs},
-@code{isblank}, @code{lgammaf}, @code{lgammal}, @code{lgamma},
-@code{llabs}, @code{llrintf}, @code{llrintl}, @code{llrint},
-@code{llroundf}, @code{llroundl}, @code{llround}, @code{log1pf},
-@code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l}, @code{log2},
-@code{logbf}, @code{logbl}, @code{logb}, @code{lrintf}, @code{lrintl},
-@code{lrint}, @code{lroundf}, @code{lroundl}, @code{lround},
-@code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
+@code{isblank}, @code{iswblank}, @code{lgammaf}, @code{lgammal},
+@code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
+@code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
+@code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
+@code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
+@code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
+@code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
@@ -5160,6 +5174,14 @@ that are recognized in any mode since ISO C90 reserves these names for
 the purpose to which ISO C99 puts them.  All these functions have
 corresponding versions prefixed with @code{__builtin_}.
 
+The ISO C94 functions
+@code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
+@code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
+@code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
+@code{towupper}
+are handled as built-in functions
+except in strict ISO C90 mode (@option{-ansi} or @option{-std=c89}).
+
 The ISO C90 functions
 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
index 6f1db4734c5dc43e2745b490c08e49514f4260b8..2d35d02bd77b31d98fb4deef7b824a6e93188a1f 100644 (file)
@@ -1,3 +1,7 @@
+2004-03-27  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * gcc.dg/torture/builtin-wctype-1.c: New test.
+
 2004-03-26  James A. Morrison  <ja2morri@uwaterloo.ca>
 
        * gcc.dg/20001013-1.c: Run on 32-bit and 64-bit SPARC.
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-wctype-1.c b/gcc/testsuite/gcc.dg/torture/builtin-wctype-1.c
new file mode 100644 (file)
index 0000000..b8338de
--- /dev/null
@@ -0,0 +1,42 @@
+/* Copyright (C) 2004  Free Software Foundation.
+
+   Verify that built-in wctype function attributes are correctly set
+   by the compiler.
+
+   Written by Kaveh Ghazi, 2004-03-25.  */
+
+/* { dg-do link } */
+
+
+void test(int i)
+{
+  /* All of these ctype functions should be const/pure and thus
+     eliminated.  */
+#define TEST_CTYPE(FN) \
+  extern int FN(int); \
+  extern void link_failure_##FN(void); \
+  if (FN(i) != FN(i)) \
+    link_failure_##FN()
+  
+#ifdef __OPTIMIZE__
+  TEST_CTYPE(iswalnum);
+  TEST_CTYPE(iswalpha);
+  TEST_CTYPE(iswblank);
+  TEST_CTYPE(iswcntrl);
+  TEST_CTYPE(iswdigit);
+  TEST_CTYPE(iswgraph);
+  TEST_CTYPE(iswlower);
+  TEST_CTYPE(iswprint);
+  TEST_CTYPE(iswpunct);
+  TEST_CTYPE(iswspace);
+  TEST_CTYPE(iswupper);
+  TEST_CTYPE(iswxdigit);
+  TEST_CTYPE(towlower);
+  TEST_CTYPE(towupper);
+#endif /* __OPTIMIZE__ */
+}
+
+int main (void)
+{
+  return 0;
+}