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]

[PATCH]: add builtin stpncpy, strcasecmp and strncasecmp


This patch adds three more builtins: stpncpy, strcasecmp and
strncasecmp.

Bootstrapped on x86_64-unknown-linux-gnu, no regressions.

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.

testsuite:
	* gcc.dg/nonnull-3.c: Also test __builtin_stpncpy,
	__builtin_strcasecmp and __builtin_strncasecmp.

diff -rup orig/egcc-CVS20050325/gcc/builtins.def egcc-CVS20050325/gcc/builtins.def
--- orig/egcc-CVS20050325/gcc/builtins.def	2005-03-25 21:27:20.000000000 -0500
+++ egcc-CVS20050325/gcc/builtins.def	2005-03-26 07:15:15.183129216 -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-CVS20050325/gcc/testsuite/gcc.dg/nonnull-3.c egcc-CVS20050325/gcc/testsuite/gcc.dg/nonnull-3.c
--- orig/egcc-CVS20050325/gcc/testsuite/gcc.dg/nonnull-3.c	2005-03-25 21:27:33.000000000 -0500
+++ egcc-CVS20050325/gcc/testsuite/gcc.dg/nonnull-3.c	2005-03-26 07:11:53.049858144 -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" } */



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