[PATCH]: add builtin stpncpy, strcasecmp and strncasecmp [TAKE 2]
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Wed Mar 30 02:41:00 GMT 2005
This revision includes updates to the documentation for the new
builtins and also for strndup which I previously installed. Thanks to
Joseph for pointing out I forget the doc bits.
Bootstrapped on x86_64-unknown-linux-gnu. Okay for mainline?
Thanks,
--Kaveh
2005-03-26 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* builtins.def (BUILT_IN_STPNCPY, BUILT_IN_STRCASECMP,
BUILT_IN_STRNCASECMP): New.
* doc/extend.texi: Document stpncpy, strcasecmp, strncasecmp
and strndup.
testsuite:
* gcc.dg/nonnull-3.c: Also test __builtin_stpncpy,
__builtin_strcasecmp and __builtin_strncasecmp.
diff -rup orig/egcc-CVS20050328/gcc/builtins.def egcc-CVS20050328/gcc/builtins.def
--- orig/egcc-CVS20050328/gcc/builtins.def 2005-03-25 21:27:20.000000000 -0500
+++ egcc-CVS20050328/gcc/builtins.def 2005-03-29 19:00:09.830975952 -0500
@@ -462,6 +462,8 @@ DEF_EXT_LIB_BUILTIN (BUILT_IN_MEMPCPY
DEF_LIB_BUILTIN (BUILT_IN_MEMSET, "memset", BT_FN_PTR_PTR_INT_SIZE, ATTR_NOTHROW_NONNULL)
DEF_EXT_LIB_BUILTIN (BUILT_IN_RINDEX, "rindex", BT_FN_STRING_CONST_STRING_INT, ATTR_PURE_NOTHROW_NONNULL)
DEF_EXT_LIB_BUILTIN (BUILT_IN_STPCPY, "stpcpy", BT_FN_STRING_STRING_CONST_STRING, ATTR_NOTHROW_NONNULL)
+DEF_EXT_LIB_BUILTIN (BUILT_IN_STPNCPY, "stpncpy", BT_FN_STRING_STRING_CONST_STRING_SIZE, ATTR_NOTHROW_NONNULL)
+DEF_EXT_LIB_BUILTIN (BUILT_IN_STRCASECMP, "strcasecmp", BT_FN_INT_CONST_STRING_CONST_STRING, ATTR_PURE_NOTHROW_NONNULL)
DEF_LIB_BUILTIN (BUILT_IN_STRCAT, "strcat", BT_FN_STRING_STRING_CONST_STRING, ATTR_NOTHROW_NONNULL)
DEF_LIB_BUILTIN (BUILT_IN_STRCHR, "strchr", BT_FN_STRING_CONST_STRING_INT, ATTR_PURE_NOTHROW_NONNULL)
DEF_LIB_BUILTIN (BUILT_IN_STRCMP, "strcmp", BT_FN_INT_CONST_STRING_CONST_STRING, ATTR_PURE_NOTHROW_NONNULL)
@@ -470,6 +472,7 @@ DEF_LIB_BUILTIN (BUILT_IN_STRCSPN
DEF_EXT_LIB_BUILTIN (BUILT_IN_STRDUP, "strdup", BT_FN_STRING_CONST_STRING, ATTR_MALLOC_NOTHROW_NONNULL)
DEF_EXT_LIB_BUILTIN (BUILT_IN_STRNDUP, "strndup", BT_FN_STRING_CONST_STRING_SIZE, ATTR_MALLOC_NOTHROW_NONNULL)
DEF_LIB_BUILTIN (BUILT_IN_STRLEN, "strlen", BT_FN_SIZE_CONST_STRING, ATTR_PURE_NOTHROW_NONNULL)
+DEF_EXT_LIB_BUILTIN (BUILT_IN_STRNCASECMP, "strncasecmp", BT_FN_INT_CONST_STRING_CONST_STRING_SIZE, ATTR_PURE_NOTHROW_NONNULL)
DEF_LIB_BUILTIN (BUILT_IN_STRNCAT, "strncat", BT_FN_STRING_STRING_CONST_STRING_SIZE, ATTR_NOTHROW_NONNULL)
DEF_LIB_BUILTIN (BUILT_IN_STRNCMP, "strncmp", BT_FN_INT_CONST_STRING_CONST_STRING_SIZE, ATTR_PURE_NOTHROW_NONNULL)
DEF_LIB_BUILTIN (BUILT_IN_STRNCPY, "strncpy", BT_FN_STRING_STRING_CONST_STRING_SIZE, ATTR_NOTHROW_NONNULL)
diff -rup orig/egcc-CVS20050328/gcc/doc/extend.texi egcc-CVS20050328/gcc/doc/extend.texi
--- orig/egcc-CVS20050328/gcc/doc/extend.texi 2005-03-22 22:19:56.000000000 -0500
+++ egcc-CVS20050328/gcc/doc/extend.texi 2005-03-29 19:04:16.143530752 -0500
@@ -4837,6 +4837,8 @@ identifier, or a sequence of member acce
@findex sqrtl
@findex sscanf
@findex stpcpy
+@findex stpncpy
+@findex strcasecmp
@findex strcat
@findex strchr
@findex strcmp
@@ -4846,9 +4848,11 @@ identifier, or a sequence of member acce
@findex strfmon
@findex strftime
@findex strlen
+@findex strncasecmp
@findex strncat
@findex strncmp
@findex strncpy
+@findex strndup
@findex strpbrk
@findex strrchr
@findex strspn
@@ -4920,9 +4924,10 @@ Outside strict ISO C mode (@option{-ansi
@code{scalb}, @code{signbit}, @code{signbitf}, @code{signbitl},
@code{significandf}, @code{significandl}, @code{significand},
@code{sincosf}, @code{sincosl}, @code{sincos}, @code{stpcpy},
-@code{strdup}, @code{strfmon}, @code{toascii}, @code{y0f}, @code{y0l},
-@code{y0}, @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
-@code{yn}
+@code{stpncpy}, @code{strcasecmp}, @code{strdup}, @code{strfmon},
+@code{strncasecmp}, @code{strndup}, @code{toascii}, @code{y0f},
+@code{y0l}, @code{y0}, @code{y1f}, @code{y1l}, @code{y1}, @code{ynf},
+@code{ynl} and @code{yn}
may be handled as built-in functions.
All these functions have corresponding versions
prefixed with @code{__builtin_}, which may be used even in strict C89
diff -rup orig/egcc-CVS20050328/gcc/testsuite/gcc.dg/nonnull-3.c egcc-CVS20050328/gcc/testsuite/gcc.dg/nonnull-3.c
--- orig/egcc-CVS20050328/gcc/testsuite/gcc.dg/nonnull-3.c 2005-03-25 21:27:33.000000000 -0500
+++ egcc-CVS20050328/gcc/testsuite/gcc.dg/nonnull-3.c 2005-03-29 19:00:09.830975952 -0500
@@ -33,10 +33,16 @@ foo (void *p, char *s)
__builtin_strncat (s, NULL, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_stpcpy (NULL, s); /* { dg-warning "null" "null pointer check" } */
__builtin_stpcpy (s, NULL); /* { dg-warning "null" "null pointer check" } */
+ __builtin_stpncpy (NULL, s, 16); /* { dg-warning "null" "null pointer check" } */
+ __builtin_stpncpy (s, NULL, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_strcpy (NULL, s); /* { dg-warning "null" "null pointer check" } */
__builtin_strcpy (s, NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_strncpy (NULL, s, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_strncpy (s, NULL, 16); /* { dg-warning "null" "null pointer check" } */
+ __builtin_strcasecmp (NULL, s); /* { dg-warning "null" "null pointer check" } */
+ __builtin_strcasecmp (s, NULL); /* { dg-warning "null" "null pointer check" } */
+ __builtin_strncasecmp (NULL, s, 16); /* { dg-warning "null" "null pointer check" } */
+ __builtin_strncasecmp (s, NULL, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_strcmp (NULL, s); /* { dg-warning "null" "null pointer check" } */
__builtin_strcmp (s, NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_strncmp (NULL, s, 16); /* { dg-warning "null" "null pointer check" } */
More information about the Gcc-patches
mailing list