* 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
+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.
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;
}
/* 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;
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);
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. */
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,
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);
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,
/* 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
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;
/* 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));
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;
= 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);
+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.
CPTI_VTBL_TYPE,
CPTI_VTBL_PTR_TYPE,
CPTI_STD,
+ CPTI_FAKE_STD,
CPTI_ABI,
CPTI_TYPE_INFO_TYPE,
CPTI_TINFO_DECL_ID,
#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]
#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]
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;
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
if (!DECL_LANG_SPECIFIC (current))
{
/* Hmm. std. */
- my_friendly_assert (current == std_node, 393);
+ my_friendly_assert (current == fake_std_node, 393);
continue;
}
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
{
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);
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)
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);
= 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
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"));
{
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)
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);
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. */
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);
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)
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)
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;
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));
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;
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)
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))
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)