This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR c++/14791
- From: Roger Sayle <roger at eyesopen dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 4 Apr 2004 08:18:50 -0600 (MDT)
- Subject: Re: [PATCH] Fix PR c++/14791
On Fri, 2 Apr 2004, Jakub Jelinek wrote:
> 2004-04-02 Jakub Jelinek <jakub@redhat.com>
>
> 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.
This is OK for mainline. You'll need to get Gaby's and Mark's permissions
for the branches.
Another standard C library builtin that is currently non-functional in
C++ for precisely the same "system type" problem is strftime. Looking
at your patch's duplicate_decls change, I suspect the best we can do is
add additional "else if (TREE_VALUE (t2) == ..." clauses, unless you can
think of a way to make it more generic?
For extra credit, I'll pre-approve a mainline patch that moves the
duplicate_decls change into its own subroutine, perhaps something like
"match_builtin_system_types", so that we prevent duplicate_decls growing
out of control (getting any worse!), and can easily update (and isolate)
"struct tm*", "time_t" and any other libc provided types in future.
Many thanks,
Roger
--
p.s. Thanks also for fixing PR c++/14755 whilst I was away.