diff options
author | Mark Mitchell <mark@codesourcery.com> | 2000-10-18 18:59:04 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2000-10-18 18:59:04 +0000 |
commit | 6bcedb4e1cdc77c336e1742cdcff7f89ecbbb660 (patch) | |
tree | 549802a7ccf67eda822a46929952ac0b0725f86e | |
parent | 989b26a751281908472e10913d6187dbb8dae7a9 (diff) | |
download | gcc-6bcedb4e1cdc77c336e1742cdcff7f89ecbbb660.zip gcc-6bcedb4e1cdc77c336e1742cdcff7f89ecbbb660.tar.gz gcc-6bcedb4e1cdc77c336e1742cdcff7f89ecbbb660.tar.bz2 |
c-common.h (flag_no_builtin): Declare.
* c-common.h (flag_no_builtin): Declare.
(flag_no_nonansi_builtin): Likewise.
(c_common_nodes_and_builtins): Change prototype.
* c-common.c (flag_no_builtin): New variable.
(flag_no_nonansi_builtin): Likewise.
(c_common_nodes_and_builtins): Remove parameters. Adjust
accordingly.
* c-decl.c (flag_no_builtin): Remove.
(flag_no_nonansi_builtin): Likewise.
(init_decl_processing): Adjust call to
c_common_nodes_and_builtins.
* cp-tree.h (cp_tree_index): Add CPTI_FAKE_STD.
(fake_std_node): New macro.
* decl.c (in_std): Rename to ...
(in_fake_std): ... this.
(flag_no_builtin): Remove.
(flag_no_nonansi_builtin): Likewise.
(walk_namespaces_r): Use fake_std_node.
(push_namespace): Use std_identifier.
(pop_namespace): Use in_fake_std.
(lookup_name_real): Use fake_std_node.
(init_decl_processing): When -fhonor-std, create the `std'
namespace. Don't create a dummy fake_std_node in that case.
Adjust call to c_common_nodes_and_builtins. Use std_identifier.
(builtin_function): Put builtins whose names don't begin
with `_' in the std namespace.
* decl2.c (flag_no_builtin): Remove.
(flag_no_nonansi_builtin): Likewise.
(set_decl_namespace): Use fake_std_node.
(validate_nonmember_using_decl): Likewise.
(do_using_directive): Likewise.
(handle_class_head): Likewise.
* dump.c (dequeue_and_dump): Likewise.
* except.c (init_exception_processing): Use std_identifier.
* init.c (build_member_call): Use fake_std_node.
* rtti.c (init_rtti_processing): Use std_identifier.
From-SVN: r36940
-rw-r--r-- | gcc/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/c-common.c | 52 | ||||
-rw-r--r-- | gcc/c-common.h | 11 | ||||
-rw-r--r-- | gcc/c-decl.c | 11 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 28 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 9 | ||||
-rw-r--r-- | gcc/cp/decl.c | 66 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 17 | ||||
-rw-r--r-- | gcc/cp/dump.c | 2 | ||||
-rw-r--r-- | gcc/cp/except.c | 2 | ||||
-rw-r--r-- | gcc/cp/init.c | 4 | ||||
-rw-r--r-- | gcc/cp/rtti.c | 2 |
12 files changed, 135 insertions, 83 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 22958f4..88c5ee6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2000-10-18 Mark Mitchell <mark@codesourcery.com> + + * c-common.h (flag_no_builtin): Declare. + (flag_no_nonansi_builtin): Likewise. + (c_common_nodes_and_builtins): Change prototype. + * c-common.c (flag_no_builtin): New variable. + (flag_no_nonansi_builtin): Likewise. + (c_common_nodes_and_builtins): Remove parameters. Adjust + accordingly. + * c-decl.c (flag_no_builtin): Remove. + (flag_no_nonansi_builtin): Likewise. + (init_decl_processing): Adjust call to + c_common_nodes_and_builtins. + 2000-10-18 Marc Espie <espie@openbsd.org> * tm.texi (LIBGCC_SPEC): Synch with reality. diff --git a/gcc/c-common.c b/gcc/c-common.c index 09cb949..086177f 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -140,6 +140,15 @@ cpp_reader parse_in; tree c_global_trees[CTI_MAX]; +/* Nonzero means don't recognize the non-ANSI builtin functions. */ + +int flag_no_builtin; + +/* Nonzero means don't recognize the non-ANSI builtin functions. + -ansi sets this. */ + +int flag_no_nonansi_builtin; + /* Nonzero means warn about possible violations of sequence point rules. */ int warn_sequence_point; @@ -4767,16 +4776,10 @@ lang_get_alias_set (t) } /* Build tree nodes and builtin functions common to both C and C++ language - frontends. - CPLUS_MODE is nonzero if we are called from the C++ frontend, we generate - some stricter prototypes in that case. - NO_BUILTINS and NO_NONANSI_BUILTINS contain the respective values of - the language frontend flags flag_no_builtin and - flag_no_nonansi_builtin. */ + frontends. */ void -c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins) - int cplus_mode, no_builtins, no_nonansi_builtins; +c_common_nodes_and_builtins () { tree temp; tree memcpy_ftype, memset_ftype, strlen_ftype; @@ -4889,7 +4892,8 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins) const_string_type_node, endlink))); - traditional_len_type_node = (flag_traditional && ! cplus_mode + traditional_len_type_node = ((flag_traditional && + c_language != clk_cplusplus) ? integer_type_node : sizetype); traditional_len_endlink = tree_cons (NULL_TREE, traditional_len_type_node, endlink); @@ -4908,9 +4912,11 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins) tree_cons (NULL_TREE, const_string_type_node, endlink)); - traditional_ptr_type_node = (flag_traditional && ! cplus_mode + traditional_ptr_type_node = ((flag_traditional && + c_language != clk_cplusplus) ? string_type_node : ptr_type_node); - traditional_cptr_type_node = (flag_traditional && ! cplus_mode + traditional_cptr_type_node = ((flag_traditional && + c_language != clk_cplusplus) ? const_string_type_node : const_ptr_type_node); /* Prototype for memcpy. */ @@ -4970,7 +4976,7 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins) BUILT_IN_NORMAL, NULL_PTR); /* Define alloca, ffs as builtins. Declare _exit just to mark it as volatile. */ - if (! no_builtins && ! no_nonansi_builtins) + if (! flag_no_builtin && ! flag_no_nonansi_builtin) { #ifndef SMALL_STACK temp = builtin_function ("alloca", ptr_ftype_sizetype, @@ -5166,7 +5172,7 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins) builtin_function ("__builtin_fputs", int_ftype_any, BUILT_IN_FPUTS, BUILT_IN_NORMAL, "fputs"); - if (! no_builtins) + if (! flag_no_builtin) { builtin_function ("abs", int_ftype_int, BUILT_IN_ABS, BUILT_IN_NORMAL, NULL_PTR); @@ -5178,7 +5184,7 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins) BUILT_IN_NORMAL, NULL_PTR); builtin_function ("labs", long_ftype_long, BUILT_IN_LABS, BUILT_IN_NORMAL, NULL_PTR); - if (flag_isoc99 || ! no_nonansi_builtins) + if (flag_isoc99 || ! flag_no_nonansi_builtin) builtin_function ("llabs", longlong_ftype_longlong, BUILT_IN_LLABS, BUILT_IN_NORMAL, NULL_PTR); builtin_function ("memcpy", memcpy_ftype, BUILT_IN_MEMCPY, @@ -5225,27 +5231,19 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins) /* Declare these functions volatile to avoid spurious "control drops through" warnings. */ - temp = builtin_function ("abort", cplus_mode ? void_ftype : void_ftype_any, + temp = builtin_function ("abort", + ((c_language == clk_cplusplus) + ? void_ftype : void_ftype_any), 0, NOT_BUILT_IN, NULL_PTR); TREE_THIS_VOLATILE (temp) = 1; TREE_SIDE_EFFECTS (temp) = 1; -#if 0 /* ??? The C++ frontend used to do this. */ - /* Well, these are actually ANSI, but we can't set DECL_BUILT_IN on - them... */ - DECL_BUILT_IN_NONANSI (temp) = 1; -#endif temp = builtin_function ("exit", - cplus_mode ? void_ftype_int : void_ftype_any, + ((c_language == clk_cplusplus) + ? void_ftype_int : void_ftype_any), 0, NOT_BUILT_IN, NULL_PTR); TREE_THIS_VOLATILE (temp) = 1; TREE_SIDE_EFFECTS (temp) = 1; - -#if 0 /* ??? The C++ frontend used to do this. */ - /* Well, these are actually ANSI, but we can't set DECL_BUILT_IN on - them... */ - DECL_BUILT_IN_NONANSI (temp) = 1; -#endif } #if 0 diff --git a/gcc/c-common.h b/gcc/c-common.h index a4bd09e..1776bad 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -370,6 +370,15 @@ extern int flag_hosted; extern int flag_noniso_default_format_attributes; +/* Nonzero means don't recognize any builtin functions. */ + +extern int flag_no_builtin; + +/* Nonzero means don't recognize the non-ANSI builtin functions. + -ansi sets this. */ + +extern int flag_no_nonansi_builtin; + /* Nonzero means warn about suggesting putting in ()'s. */ extern int warn_parentheses; @@ -454,7 +463,7 @@ extern tree c_build_qualified_type PARAMS ((tree, int)); /* Build tree nodes and builtin functions common to both C and C++ language frontends. */ -extern void c_common_nodes_and_builtins PARAMS ((int, int, int)); +extern void c_common_nodes_and_builtins PARAMS ((void)); extern tree build_va_arg PARAMS ((tree, tree)); diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 9ca6f97..8621e8a 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -343,15 +343,6 @@ int flag_short_wchar; int flag_no_asm; -/* Nonzero means don't recognize any builtin functions. */ - -int flag_no_builtin; - -/* Nonzero means don't recognize the non-ANSI builtin functions. - -ansi sets this. */ - -int flag_no_nonansi_builtin; - /* Nonzero means do some things the same way PCC does. */ int flag_traditional; @@ -3144,7 +3135,7 @@ init_decl_processing () = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (PTRDIFF_TYPE))); unsigned_ptrdiff_type_node = unsigned_type (ptrdiff_type_node); - c_common_nodes_and_builtins (0, flag_no_builtin, flag_no_nonansi_builtin); + c_common_nodes_and_builtins (); endlink = void_list_node; ptr_ftype_void = build_function_type (ptr_type_node, endlink); diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d4f8e47..f0fbee8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,31 @@ +2000-10-18 Mark Mitchell <mark@codesourcery.com> + + * cp-tree.h (cp_tree_index): Add CPTI_FAKE_STD. + (fake_std_node): New macro. + * decl.c (in_std): Rename to ... + (in_fake_std): ... this. + (flag_no_builtin): Remove. + (flag_no_nonansi_builtin): Likewise. + (walk_namespaces_r): Use fake_std_node. + (push_namespace): Use std_identifier. + (pop_namespace): Use in_fake_std. + (lookup_name_real): Use fake_std_node. + (init_decl_processing): When -fhonor-std, create the `std' + namespace. Don't create a dummy fake_std_node in that case. + Adjust call to c_common_nodes_and_builtins. Use std_identifier. + (builtin_function): Put builtins whose names don't begin + with `_' in the std namespace. + * decl2.c (flag_no_builtin): Remove. + (flag_no_nonansi_builtin): Likewise. + (set_decl_namespace): Use fake_std_node. + (validate_nonmember_using_decl): Likewise. + (do_using_directive): Likewise. + (handle_class_head): Likewise. + * dump.c (dequeue_and_dump): Likewise. + * except.c (init_exception_processing): Use std_identifier. + * init.c (build_member_call): Use fake_std_node. + * rtti.c (init_rtti_processing): Use std_identifier. + 2000-10-17 Mark Mitchell <mark@codesourcery.com> * cp-tree.h (back_end_hook): Remove declaration. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 689c859..ed25a8f 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -586,6 +586,7 @@ enum cp_tree_index CPTI_VTBL_TYPE, CPTI_VTBL_PTR_TYPE, CPTI_STD, + CPTI_FAKE_STD, CPTI_ABI, CPTI_TYPE_INFO_TYPE, CPTI_TINFO_DECL_ID, @@ -679,7 +680,14 @@ extern tree cp_global_trees[CPTI_MAX]; #define unknown_type_node cp_global_trees[CPTI_UNKNOWN_TYPE] #define vtbl_type_node cp_global_trees[CPTI_VTBL_TYPE] #define vtbl_ptr_type_node cp_global_trees[CPTI_VTBL_PTR_TYPE] +/* When the `std' namespace is a real namespace, this is the + corresponding NAMESPACE_DECL. When the `std' namespace is an alias + for the global namespace, this is NULL_TREE. */ #define std_node cp_global_trees[CPTI_STD] +/* When the `std' namespace is a real namespace, this is the + ERROR_MARK_NODE. Otherwise, this is a dummy NAMESPACE_DECL that + should be treated like the global namespace. */ +#define fake_std_node cp_global_trees[CPTI_FAKE_STD] #define abi_node cp_global_trees[CPTI_ABI] #define type_info_type_node cp_global_trees[CPTI_TYPE_INFO_TYPE] #define tinfo_decl_id cp_global_trees[CPTI_TINFO_DECL_ID] @@ -744,7 +752,6 @@ extern tree cp_global_trees[CPTI_MAX]; #define cp_push_exception_identifier cp_global_trees[CPTI_PUSH_EXCEPTION_IDENTIFIER] /* The name of the std namespace. */ #define std_identifier cp_global_trees[CPTI_STD_IDENTIFIER] - #define lang_name_c cp_global_trees[CPTI_LANG_NAME_C] #define lang_name_cplusplus cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS] #define lang_name_java cp_global_trees[CPTI_LANG_NAME_JAVA] diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 8e7443f..ee4571c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -267,8 +267,10 @@ tree cp_global_trees[CPTI_MAX]; static tree global_type_node; -/* Namespace std. */ -int in_std; +/* If non-zero, this is the number of times we have entered the `std' + namespace when we are treating that namespace as an alias for the + global namespace. */ +static int in_fake_std; /* Expect only namespace names now. */ static int only_namespace_names; @@ -354,15 +356,6 @@ int flag_noniso_default_format_attributes = 1; extern int flag_short_double; -/* Nonzero means don't recognize any builtin functions. */ - -extern int flag_no_builtin; - -/* Nonzero means don't recognize the non-ANSI builtin functions. - -ansi sets this. */ - -extern int flag_no_nonansi_builtin; - /* Nonzero if we want to conserve space in the .o files. We do this by putting uninitialized data and runtime initialized data into .common instead of .data at the expense of not flagging multiple @@ -1829,7 +1822,7 @@ walk_namespaces_r (namespace, f, data) if (!DECL_LANG_SPECIFIC (current)) { /* Hmm. std. */ - my_friendly_assert (current == std_node, 393); + my_friendly_assert (current == fake_std_node, 393); continue; } @@ -2324,9 +2317,10 @@ push_namespace (name) implicit_use = 1; } else if (current_namespace == global_namespace - && name == DECL_NAME (std_node)) + && !flag_honor_std + && name == std_identifier) { - in_std++; + in_fake_std++; return; } else @@ -2376,8 +2370,8 @@ pop_namespace () { if (current_namespace == global_namespace) { - my_friendly_assert (in_std>0, 980421); - in_std--; + my_friendly_assert (in_fake_std > 0, 980421); + in_fake_std--; return; } current_namespace = CP_DECL_CONTEXT (current_namespace); @@ -5888,7 +5882,7 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only) flags |= LOOKUP_TEMPLATES_EXPECTED; /* std:: becomes :: for now. */ - if (got_scope == std_node) + if (got_scope && got_scope == fake_std_node) got_scope = void_type_node; if (got_scope) @@ -6364,6 +6358,22 @@ init_decl_processing () NAMESPACE_LEVEL (global_namespace) = global_binding_level; declare_namespace_level (); + /* Create the `std' namespace. */ + if (flag_honor_std) + { + push_namespace (std_identifier); + std_node = current_namespace; + pop_namespace (); + fake_std_node = error_mark_node; + } + else + { + fake_std_node = build_decl (NAMESPACE_DECL, + std_identifier, + void_type_node); + pushdecl (fake_std_node); + } + /* Define `int' and `char' first so that dbx will output them first. */ record_builtin_type (RID_INT, NULL_PTR, integer_type_node); record_builtin_type (RID_CHAR, "char", char_type_node); @@ -6519,7 +6529,7 @@ init_decl_processing () = build_pointer_type (build_qualified_type (void_type_node, TYPE_QUAL_CONST)); vtt_parm_type = build_pointer_type (const_ptr_type_node); - c_common_nodes_and_builtins (1, flag_no_builtin, flag_no_nonansi_builtin); + c_common_nodes_and_builtins (); lang_type_promotes_to = convert_type_from_ellipsis; void_ftype_ptr @@ -6615,12 +6625,6 @@ init_decl_processing () layout_type (vtbl_ptr_type_node); record_builtin_type (RID_MAX, NULL_PTR, vtbl_ptr_type_node); - std_node = build_decl (NAMESPACE_DECL, - flag_honor_std - ? get_identifier ("fake std") : std_identifier, - void_type_node); - pushdecl (std_node); - if (flag_new_abi) { push_namespace (get_identifier ("__cxxabiv1")); @@ -6637,7 +6641,7 @@ init_decl_processing () { tree bad_alloc_type_node, newtype, deltype; if (flag_honor_std) - push_namespace (get_identifier ("std")); + push_namespace (std_identifier); bad_alloc_type_node = xref_tag (class_type_node, get_identifier ("bad_alloc"), 1); if (flag_honor_std) @@ -6801,10 +6805,20 @@ builtin_function (name, type, code, class, libname) my_friendly_assert (DECL_CONTEXT (decl) == NULL_TREE, 392); + /* All builtins that don't begin with an `_' should go in the `std' + namespace. */ + if (flag_honor_std && name[0] != '_') + { + push_namespace (std_identifier); + DECL_CONTEXT (decl) = std_node; + } + pushdecl (decl); + if (flag_honor_std && name[0] != '_') + pop_namespace (); + /* Since `pushdecl' relies on DECL_ASSEMBLER_NAME instead of DECL_NAME, we cannot change DECL_ASSEMBLER_NAME until we have installed this function in the namespace. */ - pushdecl (decl); if (libname) DECL_ASSEMBLER_NAME (decl) = get_identifier (libname); make_function_rtl (decl); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index fc319b7..9c61e55 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -159,15 +159,6 @@ int flag_no_asm; int flag_no_gnu_keywords; -/* Nonzero means don't recognize the non-ANSI builtin functions. */ - -int flag_no_builtin; - -/* Nonzero means don't recognize the non-ANSI builtin functions. - -ansi sets this. */ - -int flag_no_nonansi_builtin; - /* Nonzero means do some things the same way PCC does. Only provided so the compiler will link. */ @@ -4600,7 +4591,7 @@ set_decl_namespace (decl, scope, friendp) int friendp; { tree old; - if (scope == std_node) + if (scope == fake_std_node) scope = global_namespace; /* Get rid of namespace aliases. */ scope = ORIGINAL_NAMESPACE (scope); @@ -5107,7 +5098,7 @@ validate_nonmember_using_decl (decl, scope, name) tree *name; { if (TREE_CODE (decl) == SCOPE_REF - && TREE_OPERAND (decl, 0) == std_node) + && TREE_OPERAND (decl, 0) == fake_std_node) { if (namespace_bindings_p () && current_namespace == global_namespace) @@ -5353,7 +5344,7 @@ void do_using_directive (namespace) tree namespace; { - if (namespace == std_node) + if (namespace == fake_std_node) return; /* using namespace A::B::C; */ if (TREE_CODE (namespace) == SCOPE_REF) @@ -5452,7 +5443,7 @@ handle_class_head (aggr, scope, id) if (current == NULL_TREE) current = current_namespace; - if (scope == std_node) + if (scope == fake_std_node) scope = global_namespace; if (scope == NULL_TREE) scope = global_namespace; diff --git a/gcc/cp/dump.c b/gcc/cp/dump.c index 83c7db0..d528e1c 100644 --- a/gcc/cp/dump.c +++ b/gcc/cp/dump.c @@ -606,7 +606,7 @@ dequeue_and_dump (di) case NAMESPACE_DECL: /* The fake `::std' namespace does not have DECL_LANG_SPECIFIC, and therefore many other macros do not work on it. */ - if (t == std_node) + if (t == fake_std_node) break; if (DECL_NAMESPACE_ALIAS (t)) dump_child ("alis", DECL_NAMESPACE_ALIAS (t)); diff --git a/gcc/cp/except.c b/gcc/cp/except.c index a26cb1a..d3c3d16 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -143,7 +143,7 @@ init_exception_processing () tree vtype = build_function_type (void_type_node, void_list_node); if (flag_honor_std) - push_namespace (get_identifier ("std")); + push_namespace (std_identifier); terminate_node = build_cp_library_fn_ptr ("terminate", vtype); TREE_THIS_VOLATILE (terminate_node) = 1; TREE_NOTHROW (terminate_node) = 1; diff --git a/gcc/cp/init.c b/gcc/cp/init.c index e31554f..a9360e5 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1485,7 +1485,7 @@ build_member_call (type, name, parmlist) if (DECL_P (name)) name = DECL_NAME (name); - if (type == std_node) + if (type == fake_std_node) return build_x_function_call (do_scoped_id (name, 0), parmlist, current_class_ref); if (TREE_CODE (type) == NAMESPACE_DECL) @@ -1620,7 +1620,7 @@ build_offset_ref (type, name) if (TREE_CODE (name) == TEMPLATE_DECL) return name; - if (type == std_node) + if (type == fake_std_node) return do_scoped_id (name, 0); if (processing_template_decl || uses_template_parms (type)) diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 3eea2d2..f172c5f 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -80,7 +80,7 @@ void init_rtti_processing () { if (flag_honor_std) - push_namespace (get_identifier ("std")); + push_namespace (std_identifier); type_info_type_node = xref_tag (class_type_node, get_identifier ("type_info"), 1); if (flag_honor_std) |