aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/c-common.c46
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c4
4 files changed, 49 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f25661a..5fa3e72 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2001-01-01 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * c-common.c (c_common_nodes_and_builtins): Set prototype
+ parameters for __builtin_fputs, __builtin_fputc and
+ __builtin_fwrite. Don't declare plain fputc as a builtin.
+
2001-01-01 John David Anglin <dave@hiauly1.hia.nrc.ca>
* loop.c (add_label_notes): Increment the label usage count when
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 0dabe1a8..f3415479 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -5099,10 +5099,11 @@ c_common_nodes_and_builtins ()
tree temp;
tree memcpy_ftype, memset_ftype, strlen_ftype;
tree bzero_ftype, bcmp_ftype, puts_ftype, printf_ftype;
+ tree fputs_ftype, fputc_ftype, fwrite_ftype;
tree endlink, int_endlink, double_endlink, unsigned_endlink;
tree cstring_endlink, sizetype_endlink;
tree ptr_ftype, ptr_ftype_unsigned;
- tree void_ftype_any, void_ftype_int, int_ftype_any, sizet_ftype_any;
+ tree void_ftype_any, void_ftype_int, int_ftype_any;
tree double_ftype_double, double_ftype_double_double;
tree float_ftype_float, ldouble_ftype_ldouble;
tree int_ftype_cptr_cptr_sizet, sizet_ftype_cstring_cstring;
@@ -5170,7 +5171,6 @@ c_common_nodes_and_builtins ()
/* We realloc here because sizetype could be int or unsigned. S'ok. */
ptr_ftype_sizetype = build_function_type (ptr_type_node, sizetype_endlink);
- sizet_ftype_any = build_function_type (sizetype, NULL_TREE);
int_ftype_any = build_function_type (integer_type_node, NULL_TREE);
void_ftype_any = build_function_type (void_type_node, NULL_TREE);
void_ftype = build_function_type (void_type_node, endlink);
@@ -5325,6 +5325,30 @@ c_common_nodes_and_builtins ()
tree_cons (NULL_TREE, const_string_type_node,
NULL_TREE));
+ /* These stdio prototypes are declared using void* in place of
+ FILE*. They are only used for __builtin_ style calls, regular
+ style builtin prototypes omit the arguments and merge those
+ provided by stdio.h. */
+ /* Prototype for fwrite. */
+ fwrite_ftype
+ = build_function_type (c_size_type_node,
+ tree_cons (NULL_TREE, const_ptr_type_node,
+ tree_cons (NULL_TREE, c_size_type_node,
+ tree_cons (NULL_TREE, c_size_type_node,
+ tree_cons (NULL_TREE, ptr_type_node, endlink)))));
+
+ /* Prototype for fputc. */
+ fputc_ftype
+ = build_function_type (integer_type_node,
+ tree_cons (NULL_TREE, integer_type_node,
+ tree_cons (NULL_TREE, ptr_type_node, endlink)));
+
+ /* Prototype for fputs. */
+ fputs_ftype
+ = build_function_type (integer_type_node,
+ tree_cons (NULL_TREE, const_string_type_node,
+ tree_cons (NULL_TREE, ptr_type_node, endlink)));
+
builtin_function ("__builtin_constant_p", default_function_type,
BUILT_IN_CONSTANT_P, BUILT_IN_NORMAL, NULL_PTR);
@@ -5571,21 +5595,19 @@ c_common_nodes_and_builtins ()
builtin_function_2 ("__builtin_printf", "printf",
printf_ftype, printf_ftype,
BUILT_IN_PRINTF, BUILT_IN_FRONTEND, 1, 0, 0);
- /* We declare these without argument so that the initial declaration
- for these identifiers is a builtin. That allows us to redeclare
- them later with argument without worrying about the explicit
- declarations in stdio.h being taken as the initial declaration.
- Also, save the _DECL for these so we can use them later. */
built_in_decls[BUILT_IN_FWRITE] =
- builtin_function ("__builtin_fwrite", sizet_ftype_any,
+ builtin_function ("__builtin_fwrite", fwrite_ftype,
BUILT_IN_FWRITE, BUILT_IN_NORMAL, "fwrite");
built_in_decls[BUILT_IN_FPUTC] =
- builtin_function_2 ("__builtin_fputc", "fputc",
- int_ftype_any, int_ftype_any,
- BUILT_IN_FPUTC, BUILT_IN_NORMAL, 1, 0, 0);
+ builtin_function ("__builtin_fputc", fputc_ftype,
+ BUILT_IN_FPUTC, BUILT_IN_NORMAL, "fputc");
+ /* Declare the __builtin_ style with arguments and the regular style
+ without them. We rely on stdio.h to supply the arguments for the
+ regular style declaration since we had to use void* instead of
+ FILE* in the __builtin_ prototype supplied here. */
built_in_decls[BUILT_IN_FPUTS] =
builtin_function_2 ("__builtin_fputs", "fputs",
- int_ftype_any, int_ftype_any,
+ fputs_ftype, int_ftype_any,
BUILT_IN_FPUTS, BUILT_IN_NORMAL, 1, 0, 0);
/* Declare these functions non-returning
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e96e5ea..a93223c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2001-01-01 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * gcc.c-torture/execute/stdio-opt-1.c: Also test
+ __builtin_fputc and __builtin_fwrite.
+
2000-12-30 Jeffrey Oldham <oldham@codesourcery.com>
* gcc.c-torture/execute/20001009-2.c (foo): Test only works for
diff --git a/gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c b/gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c
index 061946f..78c2cc8 100644
--- a/gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c
@@ -46,6 +46,10 @@ int main()
to ensure that it works and that the prototype is correct. */
s_ptr = s_array;
__builtin_fputs ("", *s_ptr);
+ /* These builtin stubs are called by __builtin_fputs, ensure their
+ prototypes are set correctly too. */
+ __builtin_fputc ('\n', *s_ptr);
+ __builtin_fwrite ("hello\n", 1, 6, *s_ptr);
return 0;
}