diff options
author | Kaveh R. Ghazi <ghazi@caip.rutgers.edu> | 2000-12-03 03:46:03 +0000 |
---|---|---|
committer | Kaveh Ghazi <ghazi@gcc.gnu.org> | 2000-12-03 03:46:03 +0000 |
commit | d118937d79ce5f32fcc7b09acb932e559a2c16e9 (patch) | |
tree | 24241ef620273494e9e408df936e6f35081239e8 /gcc/c-common.c | |
parent | ca8034a0ea78638a2c9cdc54b13274fcb78fdfa4 (diff) | |
download | gcc-d118937d79ce5f32fcc7b09acb932e559a2c16e9.zip gcc-d118937d79ce5f32fcc7b09acb932e559a2c16e9.tar.gz gcc-d118937d79ce5f32fcc7b09acb932e559a2c16e9.tar.bz2 |
builtins.c (expand_builtin_strcat, [...]): New functions.
* builtins.c (expand_builtin_strcat, expand_builtin_strncat,
expand_builtin_strspn, expand_builtin_strcspn): New functions.
(expand_builtin): Handle BUILT_IN_STRCAT, BUILT_IN_STRNCAT,
BUILT_IN_STRSPN and BUILT_IN_STRCSPN.
* builtins.def (BUILT_IN_STRCAT, BUILT_IN_STRNCAT,
BUILT_IN_STRSPN, BUILT_IN_STRCSPN): New entries.
* c-common.c (c_common_nodes_and_builtins): Declare builtin
strcat, strncat, strspn and strcspn.
(string_ftype_string_cstring): Renamed from `string_ftype_ptr_ptr'.
* extend.texi (strcat, strcspn, strncat, strspn): Document new
builtins.
testsuite:
* gcc.c-torture/execute/string-opt-9.c: New test.
* gcc.c-torture/execute/string-opt-10.c: Likewise.
* gcc.c-torture/execute/string-opt-11.c: Likewise.
* gcc.c-torture/execute/string-opt-12.c: Likewise.
From-SVN: r37964
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 6e33945..cdbc8aa 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -4939,8 +4939,8 @@ c_common_nodes_and_builtins () tree void_ftype_any, void_ftype_int, int_ftype_any, sizet_ftype_any; tree double_ftype_double, double_ftype_double_double; tree float_ftype_float, ldouble_ftype_ldouble; - tree int_ftype_cptr_cptr_sizet; - tree int_ftype_string_string, string_ftype_ptr_ptr; + tree int_ftype_cptr_cptr_sizet, sizet_ftype_cstring_cstring; + tree int_ftype_string_string, string_ftype_string_cstring; tree string_ftype_string_int, string_ftype_string_string; tree string_ftype_string_cstring_sizet, int_ftype_cstring_cstring_sizet; tree long_ftype_long; @@ -5058,15 +5058,15 @@ c_common_nodes_and_builtins () void_zero_node = build_int_2 (0, 0); TREE_TYPE (void_zero_node) = void_type_node; - /* Prototype for strcpy. */ - string_ftype_ptr_ptr + /* Prototype for strcpy/strcat. */ + string_ftype_string_cstring = build_function_type (string_type_node, tree_cons (NULL_TREE, string_type_node, tree_cons (NULL_TREE, const_string_type_node, endlink))); - /* Prototype for strncpy. */ + /* Prototype for strncpy/strncat. */ string_ftype_string_cstring_sizet = build_function_type (string_type_node, tree_cons (NULL_TREE, string_type_node, @@ -5088,6 +5088,14 @@ c_common_nodes_and_builtins () const_string_type_node, endlink))); + /* Prototype for strspn/strcspn. */ + sizet_ftype_cstring_cstring + = build_function_type (c_size_type_node, + tree_cons (NULL_TREE, const_string_type_node, + tree_cons (NULL_TREE, + const_string_type_node, + endlink))); + /* Prototype for strncmp. */ int_ftype_cstring_cstring_sizet = build_function_type (integer_type_node, @@ -5357,12 +5365,22 @@ c_common_nodes_and_builtins () BUILT_IN_STRCHR, BUILT_IN_NORMAL, "strchr"); builtin_function ("__builtin_strrchr", string_ftype_string_int, BUILT_IN_STRRCHR, BUILT_IN_NORMAL, "strrchr"); - builtin_function ("__builtin_strcpy", string_ftype_ptr_ptr, + builtin_function ("__builtin_strcpy", string_ftype_string_cstring, BUILT_IN_STRCPY, BUILT_IN_NORMAL, "strcpy"); builtin_function ("__builtin_strncpy", string_ftype_string_cstring_sizet, BUILT_IN_STRNCPY, BUILT_IN_NORMAL, "strncpy"); - builtin_function ("__builtin_strlen", strlen_ftype, - BUILT_IN_STRLEN, BUILT_IN_NORMAL, "strlen"); + built_in_decls[BUILT_IN_STRCAT] = + builtin_function ("__builtin_strcat", string_ftype_string_cstring, + BUILT_IN_STRCAT, BUILT_IN_NORMAL, "strcat"); + builtin_function ("__builtin_strncat", string_ftype_string_cstring_sizet, + BUILT_IN_STRNCAT, BUILT_IN_NORMAL, "strncat"); + builtin_function ("__builtin_strspn", string_ftype_string_cstring, + BUILT_IN_STRSPN, BUILT_IN_NORMAL, "strspn"); + builtin_function ("__builtin_strcspn", string_ftype_string_cstring_sizet, + BUILT_IN_STRCSPN, BUILT_IN_NORMAL, "strcspn"); + built_in_decls[BUILT_IN_STRLEN] = + builtin_function ("__builtin_strlen", strlen_ftype, + BUILT_IN_STRLEN, BUILT_IN_NORMAL, "strlen"); builtin_function ("__builtin_sqrtf", float_ftype_float, BUILT_IN_FSQRT, BUILT_IN_NORMAL, "sqrtf"); builtin_function ("__builtin_fsqrt", double_ftype_double, @@ -5441,10 +5459,18 @@ c_common_nodes_and_builtins () BUILT_IN_NORMAL, NULL_PTR); builtin_function ("strpbrk", string_ftype_string_string, BUILT_IN_STRPBRK, BUILT_IN_NORMAL, NULL_PTR); - builtin_function ("strcpy", string_ftype_ptr_ptr, BUILT_IN_STRCPY, + builtin_function ("strcpy", string_ftype_string_cstring, BUILT_IN_STRCPY, BUILT_IN_NORMAL, NULL_PTR); builtin_function ("strncpy", string_ftype_string_cstring_sizet, BUILT_IN_STRNCPY, BUILT_IN_NORMAL, NULL_PTR); + builtin_function ("strcat", string_ftype_string_cstring, BUILT_IN_STRCAT, + BUILT_IN_NORMAL, NULL_PTR); + builtin_function ("strncat", string_ftype_string_cstring_sizet, + BUILT_IN_STRNCAT, BUILT_IN_NORMAL, NULL_PTR); + builtin_function ("strspn", sizet_ftype_cstring_cstring, BUILT_IN_STRSPN, + BUILT_IN_NORMAL, NULL_PTR); + builtin_function ("strcspn", sizet_ftype_cstring_cstring, + BUILT_IN_STRCSPN, BUILT_IN_NORMAL, NULL_PTR); builtin_function ("strlen", strlen_ftype, BUILT_IN_STRLEN, BUILT_IN_NORMAL, NULL_PTR); builtin_function ("sqrtf", float_ftype_float, BUILT_IN_FSQRT, |