summaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-10 08:08:02 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-10 08:08:02 +0000
commite256d445a87a788443837ca47fdf4f7bafd06d72 (patch)
tree0a102b64a167175eaefe13e2f8dbae8fe19d5fd4 /gcc/cp/decl.c
parent5c57cbb07490c2bb2fd69761cc637d0f42dd45b1 (diff)
downloadgcc-e256d445a87a788443837ca47fdf4f7bafd06d72.tar.gz
PR c++/14791
* tree.h (enum tree_index): Add TI_FILEPTR_TYPE. (fileptr_type_node): Define. * tree.c (build_common_tree_nodes_2): Initialize fileptr_type_node to ptr_type_node. * c-common.c (c_common_nodes_and_builtins): For C++, make fileptr_type_node a distinct type copy. * builtin-types.def (BT_FILEPTR, BT_FN_INT_CONST_STRING_FILEPTR, BT_FN_INT_INT_FILEPTR, BT_FN_INT_FILEPTR_CONST_STRING_VALIST_ARG, BT_FN_SIZE_CONST_PTR_SIZE_SIZE_FILEPTR, BT_FN_INT_FILEPTR_CONST_STRING_VAR): Add. (BT_FN_INT_CONST_STRING_PTR, BT_FN_INT_INT_PTR, BT_FN_SIZE_CONST_PTR_SIZE_SIZE_PTR, BT_FN_INT_PTR_CONST_STRING_VAR, BT_FN_INT_PTR_CONST_STRING_VALIST_ARG): Remove. * builtins.def (BUILT_IN_FPRINTF, BUILT_IN_FPRINTF_UNLOCKED, BUILT_IN_FPUTC, BUILT_IN_FPUTC_UNLOCKED, BUILT_IN_FPUTS, BUILT_IN_FPUTS_UNLOCKED, BUILT_IN_FSCANF, BUILT_IN_FWRITE, BUILT_IN_FWRITE_UNLOCKED, BUILT_IN_VFPRINTF, BUILT_IN_VFSCANF): Use the above *FILEPTR* types instead of *PTR*. * decl.c (duplicate_decls): Handle fileptr_type_node arguments specially. * g++.dg/opt/builtins1.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@82902 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 92f6d140b4b..ad622605280 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1200,7 +1200,40 @@ duplicate_decls (tree newdecl, tree olddecl)
{
/* Avoid warnings redeclaring anticipated built-ins. */
if (DECL_ANTICIPATED (olddecl))
- ; /* Do nothing yet. */
+ {
+ /* Deal with fileptr_type_node. FILE type is not known
+ at the time we create the builtins. */
+ tree t1, t2;
+
+ for (t1 = TYPE_ARG_TYPES (TREE_TYPE (newdecl)),
+ t2 = TYPE_ARG_TYPES (TREE_TYPE (olddecl));
+ t1 || t2;
+ t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
+ if (!t1 || !t2)
+ break;
+ else if (TREE_VALUE (t2) == fileptr_type_node)
+ {
+ tree t = TREE_VALUE (t1);
+
+ if (TREE_CODE (t) == POINTER_TYPE
+ && TYPE_NAME (TREE_TYPE (t))
+ && DECL_NAME (TYPE_NAME (TREE_TYPE (t)))
+ == get_identifier ("FILE")
+ && compparms (TREE_CHAIN (t1), TREE_CHAIN (t2)))
+ {
+ tree oldargs = TYPE_ARG_TYPES (TREE_TYPE (olddecl));
+
+ TYPE_ARG_TYPES (TREE_TYPE (olddecl))
+ = TYPE_ARG_TYPES (TREE_TYPE (newdecl));
+ types_match = decls_match (newdecl, olddecl);
+ if (types_match)
+ return duplicate_decls (newdecl, olddecl);
+ TYPE_ARG_TYPES (TREE_TYPE (olddecl)) = oldargs;
+ }
+ }
+ else if (! same_type_p (TREE_VALUE (t1), TREE_VALUE (t2)))
+ break;
+ }
else if ((DECL_EXTERN_C_P (newdecl)
&& DECL_EXTERN_C_P (olddecl))
|| compparms (TYPE_ARG_TYPES (TREE_TYPE (newdecl)),