Commit 2c73f9f5 by Martin v. Löwis Committed by Jason Merrill

massive namespace patch

From-SVN: r19631
parent 0d33d22e
......@@ -166,10 +166,15 @@ DEFTREECODE (DEFAULT_ARG, "default_arg", 'c', 2)
the template will be an IDENTIFIER_NODE. */
DEFTREECODE (TEMPLATE_ID_EXPR, "template_id_expr", 'e', 2)
/* has two fields: scope and value */
/* XXX: could recycle some of the common fields */
/* An association between namespace and entity. Parameters are the
scope and the (non-type) value.
TREE_TYPE indicates the type bound to the name. */
DEFTREECODE (CPLUS_BINDING, "binding", 'x', 2)
/* A list-like node for chaining overloading candidates. TREE_TYPE is
the original name, and the parameter is the FUNCTION_DECL. */
DEFTREECODE (OVERLOAD, "overload", 'x', 1)
/* A generic wrapper for something not tree that we want to include in
tree structure. */
DEFTREECODE (WRAPPER, "wrapper", 'x', 1)
......
......@@ -341,7 +341,7 @@ dump_aggr_type (t, v, canonical_name)
name = TYPE_NAME (canonical_name ? TYPE_MAIN_VARIANT (t) : t);
if (name && DECL_CONTEXT (name))
if (name && DECL_CONTEXT (name) && DECL_CONTEXT (name) != global_namespace)
{
/* FUNCTION_DECL or RECORD_TYPE */
dump_decl (DECL_CONTEXT (name), 0);
......@@ -710,9 +710,9 @@ dump_decl (t, v)
break;
case NAMESPACE_DECL:
if (DECL_NAMESPACE (t) != global_namespace)
if (DECL_CONTEXT (t) != global_namespace)
{
dump_decl (DECL_NAMESPACE (t), v);
dump_decl (DECL_CONTEXT (t), v);
OB_PUTC2 (':',':');
}
OB_PUTID (DECL_NAME (t));
......
......@@ -217,9 +217,13 @@ init_exception_processing ()
/* void vtype () */
tree vtype = build_function_type (void_type_node, void_list_node);
if (flag_honor_std)
push_namespace (get_identifier ("std"));
Terminate = auto_function (get_identifier ("terminate"),
vtype, NOT_BUILT_IN);
TREE_THIS_VOLATILE (Terminate) = 1;
if (flag_honor_std)
pop_namespace ();
push_lang_context (lang_name_c);
......
......@@ -34,10 +34,11 @@
/* Define terminate, unexpected, set_terminate, set_unexpected as
well as the default terminate func and default unexpected func. */
extern terminate_handler __terminate_func __attribute__((__noreturn__));
extern std::terminate_handler __terminate_func __attribute__((__noreturn__));
using std::terminate;
void
terminate ()
std::terminate ()
{
__terminate_func ();
}
......@@ -48,29 +49,29 @@ __default_unexpected ()
terminate ();
}
static unexpected_handler __unexpected_func __attribute__((__noreturn__))
static std::unexpected_handler __unexpected_func __attribute__((__noreturn__))
= __default_unexpected;
terminate_handler
set_terminate (terminate_handler func)
std::terminate_handler
std::set_terminate (std::terminate_handler func)
{
terminate_handler old = __terminate_func;
std::terminate_handler old = __terminate_func;
__terminate_func = func;
return old;
}
unexpected_handler
set_unexpected (unexpected_handler func)
std::unexpected_handler
std::set_unexpected (std::unexpected_handler func)
{
unexpected_handler old = __unexpected_func;
std::unexpected_handler old = __unexpected_func;
__unexpected_func = func;
return old;
}
void
unexpected ()
std::unexpected ()
{
__unexpected_func ();
}
......@@ -223,7 +224,7 @@ __check_eh_spec (int n, const void **spec)
try
{
unexpected ();
std::unexpected ();
}
catch (...)
{
......@@ -238,11 +239,11 @@ __check_eh_spec (int n, const void **spec)
}
}
const type_info &bad_exc = typeid (bad_exception);
const std::type_info &bad_exc = typeid (std::bad_exception);
for (int i = 0; i < n; ++i)
{
if (__throw_type_match_rtti (spec[i], &bad_exc, p->value))
throw bad_exception ();
throw std::bad_exception ();
}
terminate ();
......@@ -252,25 +253,25 @@ __check_eh_spec (int n, const void **spec)
extern "C" void
__throw_bad_cast (void)
{
throw bad_cast ();
throw std::bad_cast ();
}
extern "C" void
__throw_bad_typeid (void)
{
throw bad_typeid ();
throw std::bad_typeid ();
}
/* Has the current exception been caught? */
bool
uncaught_exception ()
std::uncaught_exception ()
{
cp_eh_info *p = __cp_exception_info ();
return p && ! p->caught;
}
const char * exception::
const char * std::exception::
what () const
{
return typeid (*this).name ();
......
......@@ -118,6 +118,10 @@ is_friend (type, supplicant)
else
context = NULL_TREE;
/* A namespace is not friend to anybody. */
if (context && TREE_CODE (context) == NAMESPACE_DECL)
context = NULL_TREE;
if (context)
return is_friend (type, context);
......
......@@ -8,7 +8,7 @@
extern "C++" {
#if 0
#ifdef __HONOR_STD
namespace std {
#endif
......@@ -34,7 +34,7 @@ unexpected_handler set_unexpected (unexpected_handler);
void unexpected (void) __attribute__ ((__noreturn__));
bool uncaught_exception ();
#if 0
#ifdef __HONOR_STD
} // namespace std
#endif
......
......@@ -10,7 +10,7 @@
extern "C++" {
#if 0
#ifdef __HONOR_STD
namespace std {
#endif
......@@ -24,7 +24,7 @@ namespace std {
typedef void (*new_handler)();
new_handler set_new_handler (new_handler);
#if 0
#ifdef __HONOR_STD
} // namespace std
#endif
......@@ -33,10 +33,10 @@ void *operator new (size_t) throw (std::bad_alloc);
void *operator new[] (size_t) throw (std::bad_alloc);
void operator delete (void *) throw();
void operator delete[] (void *) throw();
void *operator new (size_t, const nothrow_t&) throw();
void *operator new[] (size_t, const nothrow_t&) throw();
void operator delete (void *, const nothrow_t&) throw();
void operator delete[] (void *, const nothrow_t&) throw();
void *operator new (size_t, const std::nothrow_t&) throw();
void *operator new[] (size_t, const std::nothrow_t&) throw();
void operator delete (void *, const std::nothrow_t&) throw();
void operator delete[] (void *, const std::nothrow_t&) throw();
// default placement versions of operator new
inline void *operator new(size_t, void *place) throw() { return place; }
......
......@@ -5,7 +5,7 @@
#include <new>
#if 0
#ifdef __HONOR_STD
using std::new_handler;
using std::set_new_handler;
#endif
......
......@@ -8,7 +8,7 @@
extern "C++" {
#if 0
#ifdef __HONOR_STD
namespace std {
#endif
......@@ -63,7 +63,7 @@ class bad_typeid : public exception {
virtual ~bad_typeid () { }
};
#if 0
#ifdef __HONOR_STD
} // namespace std
#endif
......
......@@ -1069,22 +1069,8 @@ expand_member_init (exp, name, init)
if (fndecl)
my_friendly_assert (TREE_CODE (fndecl) == FUNCTION_DECL, 209);
/* If the field is unique, we can use the parameter
types to guide possible type instantiation. */
if (DECL_CHAIN (fndecl) == NULL_TREE)
{
/* There was a confusion here between
FIELD and FNDECL. The following code
should be correct, but abort is here
to make sure. */
my_friendly_abort (48);
parmtypes = FUNCTION_ARG_CHAIN (fndecl);
}
else
{
parmtypes = NULL_TREE;
fndecl = NULL_TREE;
}
parmtypes = NULL_TREE;
fndecl = NULL_TREE;
init = convert_arguments (parm, parmtypes, NULL_TREE, fndecl, LOOKUP_NORMAL);
if (init == NULL_TREE || TREE_TYPE (init) != error_mark_node)
......@@ -1711,10 +1697,13 @@ build_offset_ref (type, name)
/* Go from the TREE_BASELINK to the member function info. */
t = TREE_VALUE (fnfields);
if (DECL_CHAIN (t) == NULL_TREE)
if (!really_overloaded_fn (t))
{
tree access;
/* Get rid of a potential OVERLOAD around it */
t = OVL_CURRENT (t);
/* unique functions are handled easily. */
access = compute_access (basebinfo, t);
if (access == access_protected_node)
......@@ -1742,7 +1731,7 @@ build_offset_ref (type, name)
??? The smart thing to do for the case of saving initializers
is to resolve them before we're done with this scope. */
if (!TREE_PERMANENT (fnfields)
&& ((flag_save_memoized_contexts && global_bindings_p ())
&& ((flag_save_memoized_contexts && toplevel_bindings_p ())
|| ! allocation_temporary_p ()))
fnfields = copy_list (fnfields);
......
......@@ -56,6 +56,8 @@ Boston, MA 02111-1307, USA. */
"-fno-handle-exceptions",
"-fhandle-signatures",
"-fno-handle-signatures",
"-fhonor-std",
"-fno-honor-std",
"-fhuge-objects",
"-fno-huge-objects",
"-fimplement-inlines",
......
......@@ -34,6 +34,7 @@ Boston, MA 02111-1307, USA. */
-undef -D__GNUC__=%v1 -D__GNUG__=%v1 -D__cplusplus -D__GNUC_MINOR__=%v2\
%{ansi:-trigraphs -D__STRICT_ANSI__} %{!undef:%{!ansi:%p} %P}\
%{!fno-exceptions:-D__EXCEPTIONS}\
%{fhonor-std:-D__HONOR_STD} %{fnew-abi:-D__HONOR_STD}\
%c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}} %{trigraphs}\
%{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
%i %{!M:%{!MM:%{!E:%{!pipe:%g.ii}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
......
......@@ -332,7 +332,7 @@ get_time_identifier (name)
end_temporary_allocation ();
IDENTIFIER_LOCAL_VALUE (time_identifier) = build_int_2 (0, 0);
IDENTIFIER_CLASS_VALUE (time_identifier) = build_int_2 (0, 1);
IDENTIFIER_GLOBAL_VALUE (time_identifier) = filename_times;
SET_IDENTIFIER_GLOBAL_VALUE (time_identifier, filename_times);
filename_times = time_identifier;
pop_obstacks ();
}
......@@ -2740,8 +2740,8 @@ identifier_type (decl)
if (looking_for_template && really_overloaded_fn (decl))
{
tree t;
for (t = TREE_VALUE (decl); t != NULL_TREE; t = DECL_CHAIN (t))
if (DECL_FUNCTION_TEMPLATE_P (t))
for (t = decl; t != NULL_TREE; t = OVL_CHAIN (t))
if (DECL_FUNCTION_TEMPLATE_P (OVL_FUNCTION (t)))
return PFUNCNAME;
}
if (TREE_CODE (decl) == NAMESPACE_DECL)
......@@ -2758,7 +2758,8 @@ identifier_type (decl)
void
see_typename ()
{
looking_for_typename = 1;
/* Only types expected, not even namespaces. */
looking_for_typename = 2;
if (yychar < 0)
if ((yychar = yylex ()) < 0) yychar = 0;
looking_for_typename = 0;
......@@ -2827,7 +2828,7 @@ do_identifier (token, parsing)
refers to an overloaded method. Eventually this will not be
necessary, since default arguments shouldn't be parsed until
after the class is complete. (jason 3/12/97) */
&& TREE_CODE (id) != TREE_LIST)
&& TREE_CODE (id) != OVERLOAD)
pushdecl_class_level (id);
if (!id || id == error_mark_node)
......@@ -2876,7 +2877,7 @@ do_identifier (token, parsing)
}
id = error_mark_node;
/* Prevent repeated error messages. */
IDENTIFIER_NAMESPACE_VALUE (token) = error_mark_node;
SET_IDENTIFIER_NAMESPACE_VALUE (token, error_mark_node);
SET_IDENTIFIER_ERROR_LOCUS (token, current_function_decl);
}
}
......@@ -2966,7 +2967,14 @@ do_scoped_id (token, parsing)
tree id;
/* during parsing, this is ::name. Otherwise, it is black magic. */
if (parsing)
id = qualified_lookup_using_namespace (token, global_namespace);
{
struct tree_binding _b;
id = binding_init (&_b);
if (!qualified_lookup_using_namespace (token, global_namespace, id))
id = NULL_TREE;
else
id = BINDING_VALUE (id);
}
else
id = IDENTIFIER_GLOBAL_VALUE (token);
if (parsing && yychar == YYEMPTY)
......@@ -2988,14 +2996,14 @@ do_scoped_id (token, parsing)
IDENTIFIER_POINTER (token));
id = error_mark_node;
/* Prevent repeated error messages. */
IDENTIFIER_NAMESPACE_VALUE (token) = error_mark_node;
SET_IDENTIFIER_NAMESPACE_VALUE (token, error_mark_node);
}
}
else
{
if (TREE_CODE (id) == ADDR_EXPR)
mark_used (TREE_OPERAND (id, 0));
else if (TREE_CODE (id) != TREE_LIST)
else if (TREE_CODE (id) != OVERLOAD)
mark_used (id);
}
if (TREE_CODE (id) == CONST_DECL && ! processing_template_decl)
......@@ -3232,7 +3240,7 @@ real_yylex ()
&& TREE_CODE (IDENTIFIER_GLOBAL_VALUE (old_ttype)) == TYPE_DECL)
looking_for_typename = 0;
else if (ptr->token == AGGR || ptr->token == ENUM)
looking_for_typename = 1;
looking_for_typename = 2;
/* Check if this is a language-type declaration.
Just glimpse the next non-white character. */
......@@ -4375,8 +4383,6 @@ build_lang_decl (code, name, type)
DECL_LANGUAGE (t) = lang_java;
else my_friendly_abort (64);
SET_DECL_NAMESPACE (t, current_namespace);
#if 0 /* not yet, should get fixed properly later */
if (code == TYPE_DECL)
{
......@@ -4508,7 +4514,7 @@ dump_time_statistics ()
for (decl = filename_times; decl; decl = next)
{
next = IDENTIFIER_GLOBAL_VALUE (decl);
IDENTIFIER_GLOBAL_VALUE (decl) = prev;
SET_IDENTIFIER_GLOBAL_VALUE (decl, prev);
prev = decl;
}
......
......@@ -187,6 +187,7 @@ static int nrepeats = 0;
/* Array of types seen so far in top-level call to `build_mangled_name'.
Allocated and deallocated by caller. */
static tree *typevec = NULL;
static int typevec_size;
/* Number of types interned by `build_mangled_name' so far. */
static int maxtype = 0;
......@@ -418,6 +419,9 @@ build_overload_nested_name (decl)
if (ktypelist && issue_ktype (decl))
return;
if (decl == global_namespace)
return;
if (DECL_CONTEXT (decl))
{
tree context = DECL_CONTEXT (decl);
......@@ -438,14 +442,8 @@ build_overload_nested_name (decl)
}
}
}
else if (decl == global_namespace)
return;
else if (DECL_NAMESPACE (decl))
build_overload_nested_name (DECL_NAMESPACE (decl));
else
/* XXX the above does not work for non-namespaces */
if (current_namespace && TREE_CODE (decl) != NAMESPACE_DECL)
build_overload_nested_name (current_namespace);
else
my_friendly_abort (392);
if (TREE_CODE (decl) == FUNCTION_DECL)
{
......@@ -946,8 +944,8 @@ build_qualified_name (decl)
/* if we can't find a Ktype, do it the hard way */
if (check_ktype (context, FALSE) == -1)
{
/* count type scopes */
while (DECL_CONTEXT (context))
/* count type and namespace scopes */
while (DECL_CONTEXT (context) && DECL_CONTEXT (context) != global_namespace)
{
i += 1;
context = DECL_CONTEXT (context);
......@@ -956,25 +954,6 @@ build_qualified_name (decl)
if (TREE_CODE_CLASS (TREE_CODE (context)) == 't')
context = TYPE_NAME (context);
}
/* now count namespace scopes */
if (TREE_CODE (decl) == NAMESPACE_DECL)
{
i = 0; /* we have nothing done, yet: reset */
context = decl;
}
else
/* decl must be a type, which we have to scope with the
namespace */
{
/* XXX MvL somehow, types have no lang_decl, so no namespace */
context = current_namespace;
}
}
while (context != global_namespace)
{
i += 1;
context = DECL_NAMESPACE (context);
}
if (i > 1)
......@@ -1052,6 +1031,7 @@ build_mangled_name (parmtypes, begin, end)
if (!nofold && typevec)
{
/* Every argument gets counted. */
my_friendly_assert (maxtype < typevec_size, 387);
typevec[maxtype++] = parmtype;
if (TREE_USED (parmtype) && parmtype == typevec[maxtype-2]
......@@ -1588,7 +1568,11 @@ build_decl_overload_real (dname, parms, ret_type, tparms, targs,
{
maxtype = 0;
Nrepeats = 0;
typevec = (tree *)alloca (list_length (parms) * sizeof (tree));
typevec_size = list_length (parms);
if (!for_method && current_namespace != global_namespace)
/* the namespace of a global function needs one slot */
typevec_size++;
typevec = (tree *)alloca (typevec_size * sizeof (tree));
}
nofold = 0;
if (for_method)
......@@ -1596,6 +1580,7 @@ build_decl_overload_real (dname, parms, ret_type, tparms, targs,
build_mangled_name (TREE_VALUE (parms), 0, 0);
if (!flag_do_squangling) {
my_friendly_assert (maxtype < typevec_size, 387);
typevec[maxtype++] = TREE_VALUE (parms);
TREE_USED (TREE_VALUE (parms)) = 1;
}
......@@ -1611,7 +1596,10 @@ build_decl_overload_real (dname, parms, ret_type, tparms, targs,
will count as type */
if (current_namespace != global_namespace
&& !flag_do_squangling)
typevec[maxtype++] = current_namespace;
{
my_friendly_assert (maxtype < typevec_size, 387);
typevec[maxtype++] = current_namespace;
}
build_mangled_name (parms, 0, 0);
}
......@@ -1805,6 +1793,9 @@ hack_identifier (value, name)
fndecl = TREE_VALUE (fields);
my_friendly_assert (TREE_CODE (fndecl) == FUNCTION_DECL, 251);
/* I could not trigger this code. MvL */
my_friendly_abort (980325);
#ifdef DEAD
if (DECL_CHAIN (fndecl) == NULL_TREE)
{
warning ("methods cannot be converted to function pointers");
......@@ -1816,6 +1807,7 @@ hack_identifier (value, name)
IDENTIFIER_POINTER (name));
return error_mark_node;
}
#endif
}
}
if (flag_labels_ok && IDENTIFIER_LABEL_VALUE (name))
......@@ -1856,6 +1848,9 @@ hack_identifier (value, name)
}
#endif
}
else if (TREE_CODE (value) == OVERLOAD)
/* not really overloaded function */
mark_used (OVL_FUNCTION (value));
else if (TREE_CODE (value) == TREE_LIST)
{
/* Ambiguous reference to base members, possibly other cases?. */
......@@ -1866,6 +1861,9 @@ hack_identifier (value, name)
t = TREE_CHAIN (t);
}
}
else if (TREE_CODE (value) == NAMESPACE_DECL)
/* A namespace is not really expected here; this is likely illegal code. */
return value;
else
mark_used (value);
......@@ -1957,7 +1955,8 @@ make_thunk (function, delta)
if (thunk && TREE_CODE (thunk) != THUNK_DECL)
{
cp_error ("implementation-reserved name `%D' used", thunk_id);
IDENTIFIER_GLOBAL_VALUE (thunk_id) = thunk = NULL_TREE;
thunk = NULL_TREE;
SET_IDENTIFIER_GLOBAL_VALUE (thunk_id, thunk);
}
if (thunk == NULL_TREE)
{
......
......@@ -28,8 +28,9 @@
#pragma implementation "new"
#include "new"
const nothrow_t nothrow = { };
const std::nothrow_t std::nothrow = { };
using std::new_handler;
new_handler __new_handler;
new_handler
......
......@@ -26,6 +26,8 @@
// the executable file might be covered by the GNU General Public License.
#include "new"
using std::new_handler;
using std::bad_alloc;
extern "C" void *malloc (size_t);
extern new_handler __new_handler;
......@@ -35,7 +37,7 @@ extern new_handler __new_handler;
x
#ifdef L_op_newnt
WEAK (void * operator new (size_t sz, const nothrow_t&) throw())
WEAK (void * operator new (size_t sz, const std::nothrow_t&) throw())
{
void *p;
......
......@@ -41,7 +41,7 @@ WEAK(void * operator new[] (size_t sz) throw (std::bad_alloc))
#endif
#ifdef L_op_vnewnt
WEAK(void *operator new[] (size_t sz, const nothrow_t& nothrow) throw())
WEAK(void *operator new[] (size_t sz, const std::nothrow_t& nothrow) throw())
{
return ::operator new(sz, nothrow);
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -331,8 +331,10 @@ program:
{
/* In case there were missing closebraces,
get us back to the global binding level. */
while (! global_bindings_p ())
while (! toplevel_bindings_p ())
poplevel (0, 0, 0);
while (current_namespace != global_namespace)
pop_namespace ();
finish_file ();
}
;
......@@ -413,7 +415,10 @@ extdef:
{ do_toplevel_using_decl ($1); }
| USING NAMESPACE any_id ';'
{
if (TREE_CODE ($3) == IDENTIFIER_NODE)
/* If no declaration was found, the using-directive is
invalid. Since that was not reported, we need the
identifier for the error message. */
if (TREE_CODE ($3) == IDENTIFIER_NODE && lastiddecl)
$3 = lastiddecl;
do_using_directive ($3);
}
......@@ -2348,6 +2353,7 @@ left_curly:
$<ttype>0 = t;
}
if (processing_template_decl && TYPE_CONTEXT (t)
&& TREE_CODE (TYPE_CONTEXT (t)) != NAMESPACE_DECL
&& ! current_class_type)
push_template_decl (TYPE_STUB_DECL (t));
pushclass (t, 0);
......@@ -3014,7 +3020,9 @@ typename_sub2:
if (TREE_CODE ($1) != IDENTIFIER_NODE)
$1 = lastiddecl;
got_scope = $$ = complete_type (TREE_TYPE ($1));
/* Retrieve the type for the identifier, which might involve
some computation. */
got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
if ($$ == error_mark_node)
cp_error ("`%T' is not a class or namespace", $1);
......
......@@ -147,7 +147,7 @@ print_lang_identifier (file, node, indent)
tree node;
int indent;
{
print_node (file, "global", IDENTIFIER_GLOBAL_VALUE (node), indent + 4);
print_node (file, "bindings", IDENTIFIER_NAMESPACE_BINDINGS (node), indent + 4);
print_node (file, "class", IDENTIFIER_CLASS_VALUE (node), indent + 4);
print_node (file, "local", IDENTIFIER_LOCAL_VALUE (node), indent + 4);
print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4);
......@@ -169,6 +169,9 @@ lang_print_xnode (file, node, indent)
print_node (file, "value", BINDING_VALUE (node), indent+4);
print_node (file, "chain", TREE_CHAIN (node), indent+4);
break;
case OVERLOAD:
print_node (file, "function", OVL_FUNCTION (node), indent+4);
print_node (file, "chain", TREE_CHAIN (node), indent+4);
case TEMPLATE_PARM_INDEX:
indent_to (file, indent + 3);
fprintf (file, "index %d level %d orig_level %d",
......
......@@ -57,8 +57,12 @@ tree tinfo_fn_type;
void
init_rtti_processing ()
{
if (flag_honor_std)
push_namespace (get_identifier ("std"));
type_info_type_node = xref_tag
(class_type_node, get_identifier ("type_info"), NULL_TREE, 1);
if (flag_honor_std)
pop_namespace ();
tinfo_fn_id = get_identifier ("__tf");
tinfo_fn_type = build_function_type
(build_reference_type (build_type_variant (type_info_type_node, 1, 0)),
......
......@@ -1152,10 +1152,10 @@ lookup_fnfields_here (type, name)
fndecls = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), idx);
while (fndecls)
{
if (TYPE_MAIN_VARIANT (DECL_CLASS_CONTEXT (fndecls))
if (TYPE_MAIN_VARIANT (DECL_CLASS_CONTEXT (OVL_CURRENT (fndecls)))
== TYPE_MAIN_VARIANT (type))
return idx;
fndecls = TREE_CHAIN (fndecls);
fndecls = OVL_CHAIN (fndecls);
}
return -1;
}
......@@ -1266,7 +1266,7 @@ lookup_field (xbasetype, name, protect, want_type)
#ifdef GATHER_STATISTICS
n_calls_lookup_field++;
#endif /* GATHER_STATISTICS */
if (protect && flag_memoize_lookups && ! global_bindings_p ())
if (protect && flag_memoize_lookups && ! toplevel_bindings_p ())
entry = make_memoized_table_entry (type, name, 0);
else
entry = 0;
......@@ -1662,7 +1662,7 @@ lookup_fnfields_1 (type, name)
#ifdef GATHER_STATISTICS
n_outer_fields_searched++;
#endif /* GATHER_STATISTICS */
if (DECL_NAME (*methods) == name)
if (DECL_NAME (OVL_CURRENT (*methods)) == name)
break;
}
......@@ -1676,8 +1676,8 @@ lookup_fnfields_1 (type, name)
while (++methods != end)
{
if (TREE_CODE (*methods) == TEMPLATE_DECL
&& IDENTIFIER_TYPENAME_P (DECL_NAME (*methods)))
if (TREE_CODE (OVL_CURRENT (*methods)) == TEMPLATE_DECL
&& IDENTIFIER_TYPENAME_P (DECL_NAME (OVL_CURRENT (*methods))))
break;
}
}
......@@ -1815,7 +1815,7 @@ lookup_fnfields (basetype_path, name, complain)
#ifdef GATHER_STATISTICS
n_calls_lookup_fnfields++;
#endif /* GATHER_STATISTICS */
if (protect && flag_memoize_lookups && ! global_bindings_p ())
if (protect && flag_memoize_lookups && ! toplevel_bindings_p ())
entry = make_memoized_table_entry (type, name, 1);
else
entry = 0;
......@@ -2101,8 +2101,8 @@ get_virtuals_named_this (binfo)
{
tree fndecl;
for (fndecl = TREE_VALUE (fields); fndecl; fndecl = DECL_CHAIN (fndecl))
if (DECL_VINDEX (fndecl))
for (fndecl = TREE_VALUE (fields); fndecl; fndecl = OVL_NEXT (fndecl))
if (DECL_VINDEX (OVL_CURRENT (fndecl)))
return fields;
fields = next_baselink (fields);
}
......@@ -2187,8 +2187,10 @@ get_matching_virtual (binfo, fndecl, dtorp)
for (; baselink; baselink = next_baselink (baselink))
{
for (tmp = TREE_VALUE (baselink); tmp; tmp = DECL_CHAIN (tmp))
tree tmps;
for (tmps = TREE_VALUE (baselink); tmps; tmps = OVL_NEXT (tmps))
{
tmp = OVL_CURRENT (tmps);
if (! DECL_VINDEX (tmp))
continue;
......@@ -2256,7 +2258,8 @@ get_matching_virtual (binfo, fndecl, dtorp)
break;
}
}
if (tmp)
/* If not at the end */
if (tmps)
{
best = tmp;
break;
......@@ -2680,6 +2683,7 @@ dfs_debug_mark (binfo)
methods = TREE_VEC_ELT (methods, 0);
else
methods = TREE_VEC_ELT (methods, 2);
methods = OVL_CURRENT (methods);
while (methods)
{
if (DECL_VINDEX (methods)
......@@ -2697,7 +2701,7 @@ dfs_debug_mark (binfo)
/* We cannot rely on some alien method to solve our problems,
so we must write out the debug info ourselves. */
TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (t)) = 0;
rest_of_type_compilation (t, global_bindings_p ());
rest_of_type_compilation (t, toplevel_bindings_p ());
}
/* Attach to the type of the virtual base class, the pointer to the
......@@ -3471,7 +3475,7 @@ dfs_pushdecls (binfo)
{
/* This will cause lookup_name to return a pointer
to the tree_list of possible methods of this name. */
tree name = DECL_NAME (*methods);
tree name = DECL_NAME (OVL_CURRENT (*methods));
tree class_value = IDENTIFIER_CLASS_VALUE (name);
/* If the class value is not an envelope of the kind described in
......@@ -3491,7 +3495,7 @@ dfs_pushdecls (binfo)
If we can't do that, keep a TREE_LIST with possibly ambiguous
decls in there. */
maybe_push_cache_obstack ();
envelope_add_decl (type, *methods, &TREE_PURPOSE (class_value));
envelope_add_decl (type, OVL_CURRENT (*methods), &TREE_PURPOSE (class_value));
pop_obstacks ();
methods++;
......@@ -3519,7 +3523,8 @@ dfs_compress_decls (binfo)
{
/* This is known to be an envelope of the kind described before
dfs_pushdecls. */
tree class_value = IDENTIFIER_CLASS_VALUE (DECL_NAME (*methods));
tree class_value =
IDENTIFIER_CLASS_VALUE (DECL_NAME (OVL_CURRENT (*methods)));
tree tmp = TREE_PURPOSE (class_value);
/* This was replaced in scope by somebody else. Just leave it
......@@ -3529,7 +3534,7 @@ dfs_compress_decls (binfo)
if (TREE_CHAIN (tmp) == NULL_TREE
&& TREE_VALUE (tmp)
&& DECL_CHAIN (TREE_VALUE (tmp)) == NULL_TREE)
&& OVL_NEXT (TREE_VALUE (tmp)) == NULL_TREE)
{
TREE_PURPOSE (class_value) = TREE_VALUE (tmp);
}
......@@ -3738,7 +3743,7 @@ add_conversions (binfo)
for (i = 2; i < TREE_VEC_LENGTH (method_vec); ++i)
{
tree tmp = TREE_VEC_ELT (method_vec, i);
if (! IDENTIFIER_TYPENAME_P (DECL_NAME (tmp)))
if (! IDENTIFIER_TYPENAME_P (DECL_NAME (OVL_CURRENT (tmp))))
break;
conversions = scratch_tree_cons (binfo, tmp, conversions);
}
......
......@@ -96,6 +96,8 @@ build_signature_pointer_or_reference_decl (type, name)
decl = build_decl (TYPE_DECL, name, type);
TYPE_NAME (type) = decl;
TREE_CHAIN (type) = decl;
/* But we mangle it, so it needs a scope. */
DECL_CONTEXT (decl) = global_namespace;
}
/* Construct, lay out and return the type of pointers or references
......@@ -532,19 +534,20 @@ build_signature_table_constructor (sig_ty, rhs)
else
{
/* Find the class method of the correct type. */
tree rhs_methods;
basetypes = TREE_PURPOSE (baselink);
if (TREE_CODE (basetypes) == TREE_LIST)
basetypes = TREE_VALUE (basetypes);
rhs_method = TREE_VALUE (baselink);
for (; rhs_method; rhs_method = TREE_CHAIN (rhs_method))
if (sig_mname == DECL_NAME (rhs_method)
rhs_methods = TREE_VALUE (baselink);
for (; rhs_methods; rhs_methods = OVL_NEXT (rhs_methods))
if ((rhs_method = OVL_CURRENT (rhs_methods))
&& sig_mname == DECL_NAME (rhs_method)
&& ! DECL_STATIC_FUNCTION_P (rhs_method)
&& match_method_types (sig_mtype, TREE_TYPE (rhs_method)))
break;
if (rhs_method == NULL_TREE
if (rhs_methods == NULL_TREE
|| (compute_access (basetypes, rhs_method)
!= access_public_node))
{
......@@ -754,7 +757,7 @@ build_sigtable (sig_type, rhs_type, init_from)
decl = pushdecl_top_level (build_decl (VAR_DECL, name, sig_type));
current_function_decl = context;
}
IDENTIFIER_GLOBAL_VALUE (name) = decl;
SET_IDENTIFIER_GLOBAL_VALUE (name, decl);
store_init_value (decl, init_expr);
if (IS_SIGNATURE (rhs_type))
{
......
......@@ -245,6 +245,7 @@ yylex ()
{
struct token tmp_token;
tree trrr;
int old_looking_for_typename = 0;
retry:
#ifdef SPEW_DEBUG
......@@ -306,8 +307,11 @@ yylex ()
case IDENTIFIER:
scan_tokens (1);
if (nth_token (1)->yychar == SCOPE)
/* Don't interfere with the setting from an 'aggr' prefix. */
looking_for_typename++;
{
/* Don't interfere with the setting from an 'aggr' prefix. */
old_looking_for_typename = looking_for_typename;
looking_for_typename = 1;
}
else if (nth_token (1)->yychar == '<')
looking_for_template = 1;
......@@ -346,8 +350,9 @@ yylex ()
case PTYPENAME:
case PTYPENAME_DEFN:
consume_token ();
if (looking_for_typename > 0)
looking_for_typename--;
/* If we see a SCOPE next, restore the old value.
Otherwise, we got what we want. */
looking_for_typename = old_looking_for_typename;
looking_for_template = 0;
break;
......@@ -368,7 +373,7 @@ yylex ()
/* fall through to output... */
case ENUM:
/* Set this again, in case we are rescanning. */
looking_for_typename = 1;
looking_for_typename = 2;
/* fall through... */
default:
consume_token ();
......
......@@ -33,7 +33,7 @@
// that uses virtual functions and -frtti but does not actually use RTTI
// functionality.
type_info::
std::type_info::
~type_info ()
{ }
......@@ -43,7 +43,7 @@ __rtti_class (void *addr, const char *name,
{ new (addr) __class_type_info (name, bl, bn); }
extern "C" void
__rtti_si (void *addr, const char *n, const type_info *ti)
__rtti_si (void *addr, const char *n, const std::type_info *ti)
{
new (addr) __si_type_info
(n, static_cast <const __user_type_info &> (*ti));
......
......@@ -7,7 +7,7 @@
// type_info for a class with no base classes (or an enum).
struct __user_type_info : public type_info {
struct __user_type_info : public std::type_info {
__user_type_info (const char *n) : type_info (n) {}
// If our type can be converted to the desired type,
......
......@@ -29,6 +29,7 @@
#include "tinfo.h"
#include "new" // for placement new
using std::type_info;
// service function for comparing types by name.
static inline int
......
......@@ -1271,33 +1271,38 @@ debug_binfo (elem)
}
}
/* Return the length of a chain of nodes chained through DECL_CHAIN.
We expect a null pointer to mark the end of the chain.
This is the Lisp primitive `length'. */
/* Initialize an CPLUS_BINDING node that does not live on an obstack. */
int
decl_list_length (t)
tree t;
tree
binding_init (node)
struct tree_binding* node;
{
register tree tail;
register int len = 0;
my_friendly_assert (TREE_CODE (t) == FUNCTION_DECL
|| TREE_CODE (t) == TEMPLATE_DECL, 300);
for (tail = t; tail; tail = DECL_CHAIN (tail))
len++;
return len;
static struct tree_binding* source;
if (!source)
{
extern struct obstack permanent_obstack;
push_obstacks (&permanent_obstack, &permanent_obstack);
source = (struct tree_binding*)make_node (CPLUS_BINDING);
pop_obstacks ();
}
*node = *source;
TREE_PERMANENT ((tree)node) = 0;
return (tree)node;
}
int
count_functions (t)
tree t;
{
int i;
if (TREE_CODE (t) == FUNCTION_DECL)
return 1;
else if (TREE_CODE (t) == TREE_LIST)
return decl_list_length (TREE_VALUE (t));
else if (TREE_CODE (t) == OVERLOAD)
{
for (i=0; t; t = OVL_CHAIN (t))
i++;
return i;
}
my_friendly_abort (359);
return 0;
......@@ -1307,19 +1312,29 @@ int
is_overloaded_fn (x)
tree x;
{
/* XXX A baselink is also considered an overloaded function. */
if (TREE_CODE (x) == TREE_LIST)
{
my_friendly_assert (TREE_CODE (TREE_PURPOSE (x)) == TREE_VEC, 388);
x = TREE_VALUE (x);
}
return (TREE_CODE (x) == FUNCTION_DECL
|| TREE_CODE (x) == TEMPLATE_ID_EXPR
|| DECL_FUNCTION_TEMPLATE_P (x)
|| really_overloaded_fn (x));
|| TREE_CODE (x) == OVERLOAD);
}
int
really_overloaded_fn (x)
tree x;
{
return (TREE_CODE (x) == TREE_LIST
&& (TREE_CODE (TREE_VALUE (x)) == FUNCTION_DECL
|| DECL_FUNCTION_TEMPLATE_P (TREE_VALUE (x))));
/* A baselink is also considered an overloaded function.
This might also be an ambiguous class member. */
while (TREE_CODE (x) == TREE_LIST)
x = TREE_VALUE (x);
return (TREE_CODE (x) == OVERLOAD
&& (TREE_CHAIN (x) != NULL_TREE
|| DECL_FUNCTION_TEMPLATE_P (OVL_FUNCTION (x))));
}
tree
......@@ -1327,11 +1342,72 @@ get_first_fn (from)
tree from;
{
my_friendly_assert (is_overloaded_fn (from), 9);
/* A baselink is also considered an overloaded function. */
if (TREE_CODE (from) == TREE_LIST)
from = TREE_VALUE (from);
return OVL_CURRENT (from);
}
if (really_overloaded_fn (from))
return TREE_VALUE (from);
else
return from;
/* Return a new OVL node, concatenating it with the old one. */
tree
ovl_cons (decl, chain)
tree decl;
tree chain;
{
tree result = make_node (OVERLOAD);
TREE_TYPE (result) = unknown_type_node;
OVL_FUNCTION (result) = decl;
TREE_CHAIN (result) = chain;
return result;
}
/* Same as ovl_cons, but on the scratch_obstack. */
tree
scratch_ovl_cons (value, chain)
tree value, chain;
{
register tree node;
register struct obstack *ambient_obstack = current_obstack;
extern struct obstack *expression_obstack;
current_obstack = expression_obstack;
node = ovl_cons (value, chain);
current_obstack = ambient_obstack;
return node;
}
/* Build a new overloaded function. If this is the first one,
just return it; otherwise, ovl_cons the _DECLs */
tree
build_overload (decl, chain)
tree decl;
tree chain;
{
if (!chain)
return decl;
if (TREE_CODE (chain) != OVERLOAD)
chain = ovl_cons (chain, NULL_TREE);
return ovl_cons (decl, chain);
}
/* True if fn is in ovl. */
int
ovl_member (fn, ovl)
tree fn;
tree ovl;
{
if (fn == ovl)
return 1;
if (!ovl || TREE_CODE (ovl) != OVERLOAD)
return 0;
for (; ovl; ovl = OVL_CHAIN (ovl))
if (OVL_FUNCTION (ovl) == fn)
return 1;
return 0;
}
int
......@@ -2193,8 +2269,11 @@ tree
lvalue_type (arg)
tree arg;
{
tree type = TREE_TYPE (arg);
if (TREE_CODE (arg) == OVERLOAD)
type = unknown_type_node;
return cp_build_type_variant
(TREE_TYPE (arg), TREE_READONLY (arg), TREE_THIS_VOLATILE (arg));
(type, TREE_READONLY (arg), TREE_THIS_VOLATILE (arg));
}
/* The type of ARG for printing error messages; denote lvalues with
......
......@@ -91,7 +91,10 @@ require_complete_type (value)
if (processing_template_decl)
return value;
type = TREE_TYPE (value);
if (TREE_CODE (value) == OVERLOAD)
type = unknown_type_node;
else
type = TREE_TYPE (value);
/* First, detect a valid value with a complete type. */
if (TYPE_SIZE (type) != 0
......@@ -161,7 +164,7 @@ int
type_unknown_p (exp)
tree exp;
{
return (TREE_CODE (exp) == TREE_LIST
return (TREE_CODE (exp) == OVERLOAD
|| TREE_TYPE (exp) == unknown_type_node
|| (TREE_CODE (TREE_TYPE (exp)) == OFFSET_TYPE
&& TREE_TYPE (TREE_TYPE (exp)) == unknown_type_node));
......@@ -193,7 +196,8 @@ require_instantiated_type (type, exp, errval)
return errval;
}
if (TREE_TYPE (exp) == unknown_type_node
if (TREE_CODE (exp) == OVERLOAD
|| TREE_TYPE (exp) == unknown_type_node
|| (TREE_CODE (TREE_TYPE (exp)) == OFFSET_TYPE
&& TREE_TYPE (TREE_TYPE (exp)) == unknown_type_node))
{
......@@ -1837,8 +1841,12 @@ build_component_ref (datum, component, basetype_path, protect)
/* First, see if there is a field or component with name COMPONENT. */
if (TREE_CODE (component) == TREE_LIST)
{
/* I could not trigger this code. MvL */
my_friendly_abort (980326);
#ifdef DEAD
my_friendly_assert (!(TREE_CHAIN (component) == NULL_TREE
&& DECL_CHAIN (TREE_VALUE (component)) == NULL_TREE), 309);
#endif
return build (COMPONENT_REF, TREE_TYPE (component), datum, component);
}
......@@ -1907,7 +1915,7 @@ build_component_ref (datum, component, basetype_path, protect)
if (fndecls)
{
if (TREE_CHAIN (fndecls) == NULL_TREE
&& DECL_CHAIN (TREE_VALUE (fndecls)) == NULL_TREE)
&& TREE_CODE (TREE_VALUE (fndecls)) != OVERLOAD)
{
tree access, fndecl;
......@@ -2365,7 +2373,7 @@ build_x_function_call (function, params, decl)
/* A friend template. Make it look like a toplevel declaration. */
if (! is_method && TREE_CODE (function) == TEMPLATE_DECL)
function = build_scratch_list (NULL_TREE, function);
function = scratch_ovl_cons (function, NULL_TREE);
/* Handle methods, friends, and overloaded functions, respectively. */
if (is_method)
......@@ -2453,7 +2461,7 @@ build_x_function_call (function, params, decl)
}
else if (really_overloaded_fn (function))
{
if (TREE_VALUE (function) == NULL_TREE)
if (OVL_FUNCTION (function) == NULL_TREE)
{
cp_error ("function `%D' declared overloaded, but no definitions appear with which to resolve it?!?",
TREE_PURPOSE (function));
......@@ -2467,6 +2475,9 @@ build_x_function_call (function, params, decl)
return build_new_function_call (function, params);
}
}
else
/* Remove a potential OVERLOAD around it */
function = OVL_CURRENT (function);
do_x_function:
if (TREE_CODE (function) == OFFSET_REF)
......@@ -2673,7 +2684,7 @@ build_function_call_real (function, params, require_complete, flags)
&& name
&& IDENTIFIER_LENGTH (name) == 4
&& ! strcmp (IDENTIFIER_POINTER (name), "main")
&& DECL_CONTEXT (function) == NULL_TREE)
&& DECL_CONTEXT (function) == global_namespace)
{
pedwarn ("ANSI C++ forbids calling `main' from within program");
}
......@@ -4437,7 +4448,7 @@ build_unary_op (code, xarg, noconvert)
else if (pedantic
&& TREE_CODE (arg) == FUNCTION_DECL
&& DECL_NAME (arg)
&& DECL_CONTEXT (arg) == NULL_TREE
&& DECL_CONTEXT (arg) == global_namespace
&& IDENTIFIER_LENGTH (DECL_NAME (arg)) == 4
&& IDENTIFIER_POINTER (DECL_NAME (arg))[0] == 'm'
&& ! strcmp (IDENTIFIER_POINTER (DECL_NAME (arg)), "main"))
......@@ -4488,15 +4499,16 @@ build_unary_op (code, xarg, noconvert)
return build1 (ADDR_EXPR, unknown_type_node, arg);
}
if (TREE_CODE (arg) == TREE_LIST)
if (TREE_CODE (arg) == OVERLOAD)
return build1 (ADDR_EXPR, unknown_type_node, arg);
else if (TREE_CODE (arg) == TREE_LIST)
{
if (TREE_CODE (TREE_VALUE (arg)) == FUNCTION_DECL
&& DECL_CHAIN (TREE_VALUE (arg)) == NULL_TREE)
if (TREE_CODE (TREE_VALUE (arg)) == FUNCTION_DECL)
/* Unique overloaded non-member function. */
return build_unary_op (ADDR_EXPR, TREE_VALUE (arg), 0);
if (TREE_CHAIN (arg) == NULL_TREE
&& TREE_CODE (TREE_VALUE (arg)) == TREE_LIST
&& DECL_CHAIN (TREE_VALUE (TREE_VALUE (arg))) == NULL_TREE)
&& TREE_CODE (TREE_VALUE (TREE_VALUE (arg))) != OVERLOAD)
/* Unique overloaded member function. */
return build_unary_op (ADDR_EXPR, TREE_VALUE (TREE_VALUE (arg)),
0);
......@@ -6500,7 +6512,7 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum)
if (rhs == error_mark_node)
return error_mark_node;
if (TREE_VALUE (rhs) == error_mark_node)
if (TREE_CODE (rhs) == TREE_LIST && TREE_VALUE (rhs) == error_mark_node)
return error_mark_node;
if (TREE_CODE (TREE_TYPE (rhs)) == OFFSET_TYPE)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment