Commit c11b6f21 by Mike Stump

merging

From-SVN: r12700
parent 55df28b8
Wed Sep 11 22:38:13 1996 Gerald Baumgartner <gb@cs.purdue.edu>
* call.c (build_method_call): When calling a signature
default implementation, as in other cases, let instance_ptr simply
be instance.
Wed Sep 11 22:14:44 1996 Mike Stump <mrs@cygnus.com>
* parse.y (simple_stmt): Cleanup and use do_poplevel ().
Wed Sep 11 22:10:48 1996 Mike Stump <mrs@cygnus.com>
* except.c (expand_start_catch_block): Add a pushlevel so that -g
works on hppa and SPARC.
Wed Sep 11 10:18:06 1996 Brendan Kehoe <brendan@lisa.cygnus.com>
* typeck.c (build_indirect_ref): Catch PTR being an error_mark_node.
Mon Sep 9 19:51:14 1996 Gerald Baumgartner <gb@cs.purdue.edu>
* call.c (build_over_call): Check first whether DECL_CONTEXT exists
before testing whether it's a signature.
Sun Sep 8 16:06:57 1996 Gerald Baumgartner <gb@cs.purdue.edu>
* call.c (build_new_method_call): Don't complain about signature
pointers and references not being an aggr type.
(build_this): If a signature pointer or reference was passed in,
just return it.
(build_new_method_call): If instance is a signature pointer, set
basetype to the signature type of instance.
* sig.c (build_signature_method_call): Deleted basetype and
instance parameters, they can be found as the DECL_CONTEXT of
function and as the first argument passed in.
* cp-tree.h: Changed declaration of build_signature_method_call.
* call.c (build_method_call): Deleted first two arguments in call
of build_signature_method_call.
(build_over_call): Added call to build_signature_method_call.
Thu Sep 5 16:51:28 1996 Jason Merrill <jason@yorick.cygnus.com>
* typeck.c (build_c_cast): Don't tack a non_lvalue_expr onto a
target_expr.
Thu Sep 5 10:05:38 1996 Brendan Kehoe <brendan@lisa.cygnus.com>
* cvt.c (convert_to_reference): Use %#T, not %#D, for error.
Wed Sep 4 17:16:09 1996 Bob Manson <manson@charmed.cygnus.com> Wed Sep 4 17:16:09 1996 Bob Manson <manson@charmed.cygnus.com>
* except.c (expand_start_try_stmts): Move to except.c in the backend. * except.c (expand_start_try_stmts): Move to except.c in the backend.
...@@ -7,6 +56,191 @@ Wed Sep 4 17:16:09 1996 Bob Manson <manson@charmed.cygnus.com> ...@@ -7,6 +56,191 @@ Wed Sep 4 17:16:09 1996 Bob Manson <manson@charmed.cygnus.com>
of directly manipulating lists. of directly manipulating lists.
(emit_base_init): Ditto. (emit_base_init): Ditto.
Wed Sep 4 12:14:36 1996 Mike Stump <mrs@cygnus.com>
* except.c (expand_exception_blocks): Always make sure USE and
CLOBBER insns that came at the end still do, the backend relies
upon this.
Wed Sep 4 07:44:48 1996 Jason Merrill <jason@yorick.cygnus.com>
* call.c (build_over_call): We can only use a TARGET_EXPR of the
right type.
Tue Sep 3 19:26:05 1996 Jason Merrill <jason@yorick.cygnus.com>
* cvt.c (convert_to_reference): Revert last change, don't complain
about temp without target decl.
Tue Sep 3 10:22:56 1996 Mike Stump <mrs@cygnus.com>
* decl.c (grokdeclarator): Don't core dump when void() is given.
Tue Sep 3 02:38:56 1996 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (copy_args_p): Don't crash.
Fri Aug 30 14:26:57 1996 Mike Stump <mrs@cygnus.com>
* pt.c (tsubst): And support template args inside the exception
specification.
* pt.c (tsubst): Add support for exception specifications in
template functions.
Fri Aug 30 10:01:55 1996 Mike Stump <mrs@cygnus.com>
* cp-tree.def (DECL_STMT): Eliminate the throw spec field, only 3
fields now.
* cp-tree.h (start_decl): Eliminate the throw spec parameter.
(start_function): Likewise.
(start_method): Likewise.
(grokfield): Likewise.
(make_call_declarator): Add throw spec parameter.
(set_quals_and_spec): Add routine.
* lex.c (set_quals_and_spec): Likewise.
* decl.h (grokdeclarator): Eliminate the throw spec parameter.
* decl.c (shadow_tag): Eliminate the throw spec parameter to
grokdeclarator.
(groktypename): Likewise.
(start_decl): Eliminate the throw spec parameter. Eliminate the
throw spec parameter to grokdeclarator. Eliminate the throw spec
field in DECL_STMT.
(cp_finish_decl): Eliminate the throw spec field in DECL_STMT.
(grokfndecl): Remove useless set of raises.
(grokdeclarator): Eliminate the throw spec parameter. Eliminate
the throw spec parameter to start_decl. Pull the throw spec out
of the call declarator.
(grokparms): Eliminate the throw spec parameter to grokdeclarator.
(start_function): Eliminate the throw spec parameter. Eliminate
the throw spec parameter to grokdeclarator.
(start_method): Likewise.
* decl2.c (grokfield): Likewise.
(grokbitfield): Eliminate the throw spec parameter to grokdeclarator.
(grokoptypename): Likewise.
(finish_file): Eliminate the throw spec parameter to
start_function. Add throw spec to make_call_declarator.
* except.c (init_exception_processing): Add throw spec to
make_call_declarator. Eliminate the throw spec parameter to
start_decl.
(expand_start_catch_block): Eliminate the throw spec parameter to
grokdeclarator.
(expand_builtin_throw): Add throw spec to make_call_declarator.
Eliminate the throw spec parameter to start_function.
(start_anon_func): Likewise.
* lex.c (make_call_declarator): Add throw spec parameter.
(set_quals_and_spec): New routine.
(cons_up_default_function): Add throw spec to make_call_declarator.
Eliminate the throw spec parameter to grokfield.
* method.c (synthesize_method): Eliminate the throw spec parameter
to start_function.
* pt.c (process_template_parm): Eliminate the throw spec parameter
to grokdeclarator.
(tsubst): Add throw spec to make_call_declarator.
(tsubst_expr): Eliminate the throw spec parameter to start_decl.
(do_function_instantiation): Eliminate the throw spec parameter to
grokdeclarator. Eliminate the throw spec parameter to
start_function.
* rtti.c (synthesize_tinfo_fn): Eliminate the throw spec parameter
to start_function.
* parse.y (datadef): Remove non-winning optimization.
(decl): Likewise.
(fndef): Remove ambiguous error productions uncovered by grammer
fixing.
(constructor_declarator): Add exception_specification_opt here.
(component_constructor_declarator): Likewise.
(direct_after_type_declarator): Likewise.
(complex_direct_notype_declarator): Likewise.
(direct_abstract_declarator): Likewise.
(fn.def1): Remove exception_specification_opt.
(fn.def2): Likewise.
(condition): Likewise.
(initdcl0): Likewise.
(initdcl): Likewise.
(notype_initdcl0): Likewise.
(nomods_initdcl0): Likewise.
(component_decl_1): Likewise.
(component_declarator): Likewise.
(after_type_component_declarator0): Likewise.
(after_type_component_declarator): Likewise.
(notype_component_declarator): Likewise.
Wed Aug 28 01:40:30 1996 Jason Merrill <jason@yorick.cygnus.com>
* call.c (build_over_call): Also use an INIT_EXPR when
initializing anything from an rvalue.
* call.c (build_over_call): Call stabilize_reference when building
an INIT_EXPR instead of calling the copy ctor.
* call.c (joust): Extend the previous change to all comparisons.
* decl2.c, method.c, lex.c: Use MAKE_DECL_ONE_ONLY and
NO_LINKAGE_HEURISTICS.
* decl2.c (finish_file): Emit any statics that weren't already.
* typeck.c (build_static_cast): Implement.
* tree.c (build_cplus_new): Handle getting a TARGET_EXPR.
* decl.c (grokparms): Use can_convert_arg instead of
implicit_conversion directly.
(copy_args_p): New fn.
* cvt.c (convert_to_reference): Don't complain about temp with
static_cast.
(build_up_reference): Handle TARGET_EXPRs.
* call.c (build_over_call): Elide unnecessary temps.
(can_convert*): Use new overloading code.
Tue Aug 27 13:12:21 1996 Jason Merrill <jason@yorick.cygnus.com>
* call.c: Move TYPE_PTR*_MACROS ...
* cp-tree.h: To here.
* typeck.c (build_reinterpret_cast): Implement.
* call.c (add_builtin_candidate): Use TYPE_PTROB_P instead of
ptr_complete_ob.
(joust): If we're comparing a function to a builtin and the worst
conversion for the builtin is worse than the worst conversion for the
function, take the function.
* typeck.c (build_const_cast): Implement.
(comp_ptr_ttypes_const): Like comp_ptr_ttypes, for const_cast.
(comp_ptr_ttypes_reinterpret): Like cpt, for reinterpret_cast.
Tue Aug 27 13:14:58 1996 Bob Manson <manson@charmed.cygnus.com>
* rtti.c (build_dynamic_cast): Don't try to dereference exprtype
too early. Make sure we explode if exprtype turns out to be a
NULL_TREE when it shouldn't be.
Tue Aug 27 10:56:21 1996 Mike Stump <mrs@cygnus.com>
* cp-tree.h: New routine make_call_declarator.
* lex.c (make_call_declarator): Define it.
* except.c (init_exception_processing): Use it.
(expand_builtin_throw): Likewise.
(start_anon_func): Likewise.
* decl2.c (finish_file): Likewise.
* lex.c (cons_up_default_function): Likewise.
* parse.y: Likewise.
* pt.c (tsubst): Likewise.
Mon Aug 26 17:40:03 1996 Mike Stump <mrs@cygnus.com>
* decl2.c (groktypefield): Remove unused code.
Mon Aug 26 17:00:33 1996 Mike Stump <mrs@cygnus.com>
* gxx.gperf: Change TYPE_QUAL into CV_QUALIFIER.
* parse.y: Likewise. Change maybe_type_qual into maybe_cv_qualifier.
Change type_quals into cv_qualifiers. Change nonempty_type_quals into
nonempty_cv_qualifiers.
* hash.h: Rebuild.
* lex.c (make_pointer_declarator): Change type_quals into
cv_qualifiers.
(make_reference_declarator): Likewise.
Thu Aug 22 01:09:22 1996 Jason Merrill <jason@yorick.cygnus.com> Thu Aug 22 01:09:22 1996 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (start_function): Only check interface_* for templates * decl.c (start_function): Only check interface_* for templates
...@@ -122,10 +356,6 @@ Tue Aug 13 12:16:10 1996 Jason Merrill <jason@yorick.cygnus.com> ...@@ -122,10 +356,6 @@ Tue Aug 13 12:16:10 1996 Jason Merrill <jason@yorick.cygnus.com>
(import_export_decl): Use it. (import_export_decl): Use it.
* method.c (make_thunk): Use it. * method.c (make_thunk): Use it.
Sat Aug 17 15:23:39 1996 Geoffrey Noer <noer@cygnus.com>
* g++.c: Update test for win32 (&& ! cygwin32).
Mon Aug 12 00:09:18 1996 Jason Merrill <jason@yorick.cygnus.com> Mon Aug 12 00:09:18 1996 Jason Merrill <jason@yorick.cygnus.com>
* pt.c (end_template_decl): If we don't actually have parms, return. * pt.c (end_template_decl): If we don't actually have parms, return.
......
...@@ -668,24 +668,6 @@ user_harshness (type, parmtype) ...@@ -668,24 +668,6 @@ user_harshness (type, parmtype)
return -1; return -1;
} }
int
can_convert (to, from)
tree to, from;
{
struct harshness_code h;
h = convert_harshness (to, from, NULL_TREE);
return (h.code < USER_CODE) && (h.distance >= 0);
}
int
can_convert_arg (to, from, arg)
tree to, from, arg;
{
struct harshness_code h;
h = convert_harshness (to, from, arg);
return (h.code < USER_CODE) && (h.distance >= 0);
}
#ifdef DEBUG_MATCHING #ifdef DEBUG_MATCHING
static char * static char *
print_harshness (h) print_harshness (h)
...@@ -1865,8 +1847,7 @@ build_method_call (instance, name, parms, basetype_path, flags) ...@@ -1865,8 +1847,7 @@ build_method_call (instance, name, parms, basetype_path, flags)
&& TYPE_IDENTIFIER (basetype) != name) && TYPE_IDENTIFIER (basetype) != name)
{ {
basetype = SIGNATURE_TYPE (basetype); basetype = SIGNATURE_TYPE (basetype);
instance_ptr = build_optr_ref (instance); instance_ptr = instance;
instance_ptr = convert (build_pointer_type (basetype), instance_ptr);
basetype_path = TYPE_BINFO (basetype); basetype_path = TYPE_BINFO (basetype);
} }
else else
...@@ -2462,7 +2443,7 @@ build_method_call (instance, name, parms, basetype_path, flags) ...@@ -2462,7 +2443,7 @@ build_method_call (instance, name, parms, basetype_path, flags)
basetype, save_name); basetype, save_name);
return error_mark_node; return error_mark_node;
} }
return build_signature_method_call (basetype, instance, function, parms); return build_signature_method_call (function, parms);
} }
function = DECL_MAIN_VARIANT (function); function = DECL_MAIN_VARIANT (function);
...@@ -3461,27 +3442,6 @@ add_conv_candidate (candidates, fn, obj, arglist) ...@@ -3461,27 +3442,6 @@ add_conv_candidate (candidates, fn, obj, arglist)
return cand; return cand;
} }
int
ptr_complete_ob (t)
tree t;
{
return (TREE_CODE (t) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (t)) != OFFSET_TYPE
&& TREE_CODE (TREE_TYPE (t)) != FUNCTION_TYPE
&& TREE_CODE (TREE_TYPE (t)) != VOID_TYPE
&& TYPE_SIZE (complete_type (TREE_TYPE (t))) != NULL_TREE);
}
#define TYPE_PTRMEM_P(NODE) \
(TREE_CODE (NODE) == POINTER_TYPE \
&& TREE_CODE (TREE_TYPE (NODE)) == OFFSET_TYPE)
#define TYPE_PTR_P(NODE) \
(TREE_CODE (NODE) == POINTER_TYPE \
&& TREE_CODE (TREE_TYPE (NODE)) != OFFSET_TYPE)
#define TYPE_PTROB_P(NODE) \
(TYPE_PTR_P (NODE) && TREE_CODE (TREE_TYPE (NODE)) != FUNCTION_TYPE \
&& TREE_CODE (TREE_TYPE (NODE)) != VOID_TYPE)
static struct z_candidate * static struct z_candidate *
build_builtin_candidate (candidates, fnname, type1, type2, build_builtin_candidate (candidates, fnname, type1, type2,
args, argtypes, flags) args, argtypes, flags)
...@@ -3598,7 +3558,7 @@ add_builtin_candidate (candidates, code, code2, fnname, type1, type2, ...@@ -3598,7 +3558,7 @@ add_builtin_candidate (candidates, code, code2, fnname, type1, type2,
case POSTINCREMENT_EXPR: case POSTINCREMENT_EXPR:
case PREINCREMENT_EXPR: case PREINCREMENT_EXPR:
if ((ARITHMETIC_TYPE_P (type1) && TREE_CODE (type1) != ENUMERAL_TYPE) if ((ARITHMETIC_TYPE_P (type1) && TREE_CODE (type1) != ENUMERAL_TYPE)
|| ptr_complete_ob (type1)) || TYPE_PTROB_P (type1))
{ {
type1 = build_reference_type (type1); type1 = build_reference_type (type1);
break; break;
...@@ -3616,7 +3576,7 @@ add_builtin_candidate (candidates, code, code2, fnname, type1, type2, ...@@ -3616,7 +3576,7 @@ add_builtin_candidate (candidates, code, code2, fnname, type1, type2,
case INDIRECT_REF: case INDIRECT_REF:
if (TREE_CODE (type1) == POINTER_TYPE if (TREE_CODE (type1) == POINTER_TYPE
&& (ptr_complete_ob (type1) && (TYPE_PTROB_P (type1)
|| TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE)) || TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE))
break; break;
return candidates; return candidates;
...@@ -3713,9 +3673,9 @@ add_builtin_candidate (candidates, code, code2, fnname, type1, type2, ...@@ -3713,9 +3673,9 @@ add_builtin_candidate (candidates, code, code2, fnname, type1, type2,
bool operator!=(T, T); */ bool operator!=(T, T); */
case MINUS_EXPR: case MINUS_EXPR:
if (ptr_complete_ob (type1) && ptr_complete_ob (type2)) if (TYPE_PTROB_P (type1) && TYPE_PTROB_P (type2))
break; break;
if (ptr_complete_ob (type1) && INTEGRAL_TYPE_P (type2)) if (TYPE_PTROB_P (type1) && INTEGRAL_TYPE_P (type2))
{ {
type2 = ptrdiff_type_node; type2 = ptrdiff_type_node;
break; break;
...@@ -3768,12 +3728,12 @@ add_builtin_candidate (candidates, code, code2, fnname, type1, type2, ...@@ -3768,12 +3728,12 @@ add_builtin_candidate (candidates, code, code2, fnname, type1, type2,
if (ARITHMETIC_TYPE_P (type1) && ARITHMETIC_TYPE_P (type2)) if (ARITHMETIC_TYPE_P (type1) && ARITHMETIC_TYPE_P (type2))
break; break;
case ARRAY_REF: case ARRAY_REF:
if (INTEGRAL_TYPE_P (type1) && ptr_complete_ob (type2)) if (INTEGRAL_TYPE_P (type1) && TYPE_PTROB_P (type2))
{ {
type1 = ptrdiff_type_node; type1 = ptrdiff_type_node;
break; break;
} }
if (ptr_complete_ob (type1) && INTEGRAL_TYPE_P (type2)) if (TYPE_PTROB_P (type1) && INTEGRAL_TYPE_P (type2))
{ {
type2 = ptrdiff_type_node; type2 = ptrdiff_type_node;
break; break;
...@@ -3842,7 +3802,7 @@ add_builtin_candidate (candidates, code, code2, fnname, type1, type2, ...@@ -3842,7 +3802,7 @@ add_builtin_candidate (candidates, code, code2, fnname, type1, type2,
{ {
case PLUS_EXPR: case PLUS_EXPR:
case MINUS_EXPR: case MINUS_EXPR:
if (ptr_complete_ob (type1) && INTEGRAL_TYPE_P (type2)) if (TYPE_PTROB_P (type1) && INTEGRAL_TYPE_P (type2))
{ {
type2 = ptrdiff_type_node; type2 = ptrdiff_type_node;
break; break;
...@@ -4164,6 +4124,10 @@ build_this (obj) ...@@ -4164,6 +4124,10 @@ build_this (obj)
tree obj; tree obj;
{ {
/* Fix this to work on non-lvalues. */ /* Fix this to work on non-lvalues. */
if (IS_SIGNATURE_POINTER (TREE_TYPE (obj))
|| IS_SIGNATURE_REFERENCE (TREE_TYPE (obj)))
return obj;
else
return build_unary_op (ADDR_EXPR, obj, 0); return build_unary_op (ADDR_EXPR, obj, 0);
} }
...@@ -5096,6 +5060,67 @@ build_over_call (fn, convs, args, flags) ...@@ -5096,6 +5060,67 @@ build_over_call (fn, convs, args, flags)
converted_args = nreverse (converted_args); converted_args = nreverse (converted_args);
/* Avoid actually calling copy constructors and copy assignment operators,
if possible. */
if (DECL_CONSTRUCTOR_P (fn)
&& TREE_VEC_LENGTH (convs) == 1
&& copy_args_p (fn))
{
tree targ = NULL_TREE;
arg = TREE_VALUE (TREE_CHAIN (converted_args));
/* Pull out the real argument, disregarding const-correctness. */
if (TREE_CODE (arg) == ADDR_EXPR)
{
targ = TREE_OPERAND (arg, 0);
if (! comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (arg))),
TYPE_MAIN_VARIANT (TREE_TYPE (targ)), 1))
targ = NULL_TREE;
}
if (targ)
arg = targ;
else
arg = build_indirect_ref (arg, 0);
/* If we're creating a temp and we already have one, don't create a
new one. If we're not creating a temp but we get one, use
INIT_EXPR to collapse the temp into our target. Otherwise, if the
ctor is trivial, do a bitwise copy with a simple TARGET_EXPR for a
temp or an INIT_EXPR otherwise. */
if (integer_zerop (TREE_VALUE (args)))
{
if (! real_lvalue_p (arg))
return arg;
else if (TYPE_HAS_TRIVIAL_INIT_REF (DECL_CONTEXT (fn)))
{
val = build (VAR_DECL, DECL_CONTEXT (fn));
layout_decl (val, 0);
return build (TARGET_EXPR, DECL_CONTEXT (fn), val, arg, 0, 0);
}
}
else if (! real_lvalue_p (arg)
|| TYPE_HAS_TRIVIAL_INIT_REF (DECL_CONTEXT (fn)))
{
tree to = stabilize_reference
(build_indirect_ref (TREE_VALUE (args), 0));
val = build (INIT_EXPR, DECL_CONTEXT (fn), to, arg);
TREE_SIDE_EFFECTS (val) = 1;
return build_unary_op (ADDR_EXPR, val, 0);
}
}
else if (DECL_NAME (fn) == ansi_opname[MODIFY_EXPR]
&& copy_args_p (fn)
&& TYPE_HAS_TRIVIAL_ASSIGN_REF (DECL_CONTEXT (fn)))
{
tree to = stabilize_reference
(build_indirect_ref (TREE_VALUE (converted_args), 0));
arg = build_indirect_ref (TREE_VALUE (TREE_CHAIN (converted_args)), 0);
val = build (MODIFY_EXPR, TREE_TYPE (to), to, arg);
TREE_SIDE_EFFECTS (val) = 1;
return val;
}
mark_used (fn); mark_used (fn);
if (pedantic && DECL_THIS_INLINE (fn) && ! DECL_ARTIFICIAL (fn) if (pedantic && DECL_THIS_INLINE (fn) && ! DECL_ARTIFICIAL (fn)
...@@ -5104,7 +5129,9 @@ build_over_call (fn, convs, args, flags) ...@@ -5104,7 +5129,9 @@ build_over_call (fn, convs, args, flags)
&& TREE_LANG_FLAG_0 (DECL_TEMPLATE_INFO (fn)))) && TREE_LANG_FLAG_0 (DECL_TEMPLATE_INFO (fn))))
cp_warning ("inline function `%#D' called before definition", fn); cp_warning ("inline function `%#D' called before definition", fn);
if (DECL_VINDEX (fn) && (flags & LOOKUP_NONVIRTUAL) == 0) if (DECL_CONTEXT (fn) && IS_SIGNATURE (DECL_CONTEXT (fn)))
return build_signature_method_call (fn, converted_args);
else if (DECL_VINDEX (fn) && (flags & LOOKUP_NONVIRTUAL) == 0)
{ {
tree t, *p = &TREE_VALUE (converted_args); tree t, *p = &TREE_VALUE (converted_args);
tree binfo = get_binfo tree binfo = get_binfo
...@@ -5153,7 +5180,10 @@ build_new_method_call (instance, name, args, basetype_path, flags) ...@@ -5153,7 +5180,10 @@ build_new_method_call (instance, name, args, basetype_path, flags)
basetype = TREE_TYPE (instance); basetype = TREE_TYPE (instance);
/* XXX this should be handled before we get here. */ /* XXX this should be handled before we get here. */
if (! IS_AGGR_TYPE (basetype)) if (! IS_AGGR_TYPE (basetype)
&& ! (TYPE_LANG_SPECIFIC (basetype)
&& (IS_SIGNATURE_POINTER (basetype)
|| IS_SIGNATURE_REFERENCE (basetype))))
{ {
if ((flags & LOOKUP_COMPLAIN) && basetype != error_mark_node) if ((flags & LOOKUP_COMPLAIN) && basetype != error_mark_node)
cp_error ("request for member `%D' in `%E', which is of non-aggregate type `%T'", cp_error ("request for member `%D' in `%E', which is of non-aggregate type `%T'",
...@@ -5161,6 +5191,14 @@ build_new_method_call (instance, name, args, basetype_path, flags) ...@@ -5161,6 +5191,14 @@ build_new_method_call (instance, name, args, basetype_path, flags)
return error_mark_node; return error_mark_node;
} }
/* If `instance' is a signature pointer/reference and `name' is
not a constructor, we are calling a signature member function.
In that case set the `basetype' to the signature type. */
if ((IS_SIGNATURE_POINTER (basetype)
|| IS_SIGNATURE_REFERENCE (basetype))
&& TYPE_IDENTIFIER (basetype) != name)
basetype = SIGNATURE_TYPE (basetype);
} }
if (basetype_path == NULL_TREE) if (basetype_path == NULL_TREE)
...@@ -5587,7 +5625,10 @@ joust (cand1, cand2) ...@@ -5587,7 +5625,10 @@ joust (cand1, cand2)
if (comp != 0) if (comp != 0)
{ {
if (winner && comp != winner) if (winner && comp != winner)
return 0; {
winner = 0;
goto tweak;
}
winner = comp; winner = comp;
} }
} }
...@@ -5621,7 +5662,7 @@ joust (cand1, cand2) ...@@ -5621,7 +5662,7 @@ joust (cand1, cand2)
if (! winner && cand1->fn == cand2->fn if (! winner && cand1->fn == cand2->fn
&& TREE_CODE (cand1->fn) == IDENTIFIER_NODE) && TREE_CODE (cand1->fn) == IDENTIFIER_NODE)
{ {
for (i = 0; i < TREE_VEC_LENGTH (cand1->convs); ++i) for (i = 0; i < len; ++i)
if (! comptypes (TREE_TYPE (TREE_VEC_ELT (cand1->convs, i)), if (! comptypes (TREE_TYPE (TREE_VEC_ELT (cand1->convs, i)),
TREE_TYPE (TREE_VEC_ELT (cand2->convs, i)), 1)) TREE_TYPE (TREE_VEC_ELT (cand2->convs, i)), 1))
break; break;
...@@ -5646,6 +5687,28 @@ joust (cand1, cand2) ...@@ -5646,6 +5687,28 @@ joust (cand1, cand2)
} }
} }
tweak:
/* Extension: If the worst conversion for one candidate is worse than the
worst conversion for the other, take the first. */
if (! winner && ! pedantic)
{
int rank1 = IDENTITY_RANK, rank2 = IDENTITY_RANK;
for (i = 0; i < len; ++i)
{
if (ICS_RANK (TREE_VEC_ELT (cand1->convs, i+off1)) > rank1)
rank1 = ICS_RANK (TREE_VEC_ELT (cand1->convs, i+off1));
if (ICS_RANK (TREE_VEC_ELT (cand2->convs, i+off2)) > rank2)
rank2 = ICS_RANK (TREE_VEC_ELT (cand2->convs, i+off2));
}
if (rank1 < rank2)
return 1;
if (rank1 > rank2)
return -1;
}
return winner; return winner;
} }
...@@ -5698,3 +5761,37 @@ tourney (candidates) ...@@ -5698,3 +5761,37 @@ tourney (candidates)
return champ; return champ;
} }
int
can_convert (to, from)
tree to, from;
{
if (flag_ansi_overloading)
{
tree t = implicit_conversion (to, from, NULL_TREE, LOOKUP_NORMAL);
return (t && ! ICS_BAD_FLAG (t));
}
else
{
struct harshness_code h;
h = convert_harshness (to, from, NULL_TREE);
return (h.code < USER_CODE) && (h.distance >= 0);
}
}
int
can_convert_arg (to, from, arg)
tree to, from, arg;
{
if (flag_ansi_overloading)
{
tree t = implicit_conversion (to, from, arg, LOOKUP_NORMAL);
return (t && ! ICS_BAD_FLAG (t));
}
else
{
struct harshness_code h;
h = convert_harshness (to, from, arg);
return (h.code < USER_CODE) && (h.distance >= 0);
}
}
...@@ -123,7 +123,7 @@ DEFTREECODE (DOTSTAR_EXPR, "dotstar_expr", "e", 2) ...@@ -123,7 +123,7 @@ DEFTREECODE (DOTSTAR_EXPR, "dotstar_expr", "e", 2)
DEFTREECODE (EXPR_STMT, "expr_stmt", "e", 1) DEFTREECODE (EXPR_STMT, "expr_stmt", "e", 1)
DEFTREECODE (COMPOUND_STMT, "compound_stmt", "e", 1) DEFTREECODE (COMPOUND_STMT, "compound_stmt", "e", 1)
DEFTREECODE (DECL_STMT, "decl_stmt", "e", 4) DEFTREECODE (DECL_STMT, "decl_stmt", "e", 3)
DEFTREECODE (IF_STMT, "if_stmt", "e", 3) DEFTREECODE (IF_STMT, "if_stmt", "e", 3)
DEFTREECODE (FOR_STMT, "for_stmt", "e", 4) DEFTREECODE (FOR_STMT, "for_stmt", "e", 4)
DEFTREECODE (WHILE_STMT, "while_stmt", "e", 2) DEFTREECODE (WHILE_STMT, "while_stmt", "e", 2)
......
...@@ -1265,6 +1265,21 @@ extern int flag_new_for_scope; ...@@ -1265,6 +1265,21 @@ extern int flag_new_for_scope;
#define TYPE_HAS_TRIVIAL_ASSIGN_REF(NODE) \ #define TYPE_HAS_TRIVIAL_ASSIGN_REF(NODE) \
(TYPE_HAS_ASSIGN_REF (NODE) && ! TYPE_HAS_COMPLEX_ASSIGN_REF (NODE)) (TYPE_HAS_ASSIGN_REF (NODE) && ! TYPE_HAS_COMPLEX_ASSIGN_REF (NODE))
#define TYPE_PTRMEM_P(NODE) \
(TREE_CODE (NODE) == POINTER_TYPE \
&& TREE_CODE (TREE_TYPE (NODE)) == OFFSET_TYPE)
#define TYPE_PTR_P(NODE) \
(TREE_CODE (NODE) == POINTER_TYPE \
&& TREE_CODE (TREE_TYPE (NODE)) != OFFSET_TYPE)
#define TYPE_PTROB_P(NODE) \
(TYPE_PTR_P (NODE) && TREE_CODE (TREE_TYPE (NODE)) != FUNCTION_TYPE \
&& TREE_CODE (TREE_TYPE (NODE)) != VOID_TYPE)
#define TYPE_PTROBV_P(NODE) \
(TYPE_PTR_P (NODE) && TREE_CODE (TREE_TYPE (NODE)) != FUNCTION_TYPE)
#define TYPE_PTRFN_P(NODE) \
(TREE_CODE (NODE) == POINTER_TYPE \
&& TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE)
/* Nonzero for _TYPE node means that this type is a pointer to member /* Nonzero for _TYPE node means that this type is a pointer to member
function type. */ function type. */
#define TYPE_PTRMEMFUNC_P(NODE) (TREE_CODE(NODE) == RECORD_TYPE && TYPE_LANG_SPECIFIC(NODE)->type_flags.ptrmemfunc_flag) #define TYPE_PTRMEMFUNC_P(NODE) (TREE_CODE(NODE) == RECORD_TYPE && TYPE_LANG_SPECIFIC(NODE)->type_flags.ptrmemfunc_flag)
...@@ -2047,7 +2062,7 @@ extern int init_type_desc PROTO((void)); ...@@ -2047,7 +2062,7 @@ extern int init_type_desc PROTO((void));
extern void shadow_tag PROTO((tree)); extern void shadow_tag PROTO((tree));
extern int grok_ctor_properties PROTO((tree, tree)); extern int grok_ctor_properties PROTO((tree, tree));
extern tree groktypename PROTO((tree)); extern tree groktypename PROTO((tree));
extern tree start_decl PROTO((tree, tree, int, tree)); extern tree start_decl PROTO((tree, tree, int));
extern void cp_finish_decl PROTO((tree, tree, tree, int, int)); extern void cp_finish_decl PROTO((tree, tree, tree, int, int));
extern void expand_static_init PROTO((tree, tree)); extern void expand_static_init PROTO((tree, tree));
extern int complete_array_type PROTO((tree, tree, int)); extern int complete_array_type PROTO((tree, tree, int));
...@@ -2061,13 +2076,13 @@ extern tree start_enum PROTO((tree)); ...@@ -2061,13 +2076,13 @@ extern tree start_enum PROTO((tree));
extern tree finish_enum PROTO((tree, tree)); extern tree finish_enum PROTO((tree, tree));
extern tree build_enumerator PROTO((tree, tree)); extern tree build_enumerator PROTO((tree, tree));
extern tree grok_enum_decls PROTO((tree, tree)); extern tree grok_enum_decls PROTO((tree, tree));
extern int start_function PROTO((tree, tree, tree, tree, int)); extern int start_function PROTO((tree, tree, tree, int));
extern void store_parm_decls PROTO((void)); extern void store_parm_decls PROTO((void));
extern void expand_start_early_try_stmts PROTO((void)); extern void expand_start_early_try_stmts PROTO((void));
extern void store_in_parms PROTO((struct rtx_def *)); extern void store_in_parms PROTO((struct rtx_def *));
extern void store_return_init PROTO((tree, tree)); extern void store_return_init PROTO((tree, tree));
extern void finish_function PROTO((int, int, int)); extern void finish_function PROTO((int, int, int));
extern tree start_method PROTO((tree, tree, tree)); extern tree start_method PROTO((tree, tree));
extern tree finish_method PROTO((tree)); extern tree finish_method PROTO((tree));
extern void hack_incomplete_structures PROTO((tree)); extern void hack_incomplete_structures PROTO((tree));
extern tree maybe_build_cleanup PROTO((tree)); extern tree maybe_build_cleanup PROTO((tree));
...@@ -2092,7 +2107,7 @@ extern tree grok_alignof PROTO((tree)); ...@@ -2092,7 +2107,7 @@ extern tree grok_alignof PROTO((tree));
extern tree grok_array_decl PROTO((tree, tree)); extern tree grok_array_decl PROTO((tree, tree));
extern tree delete_sanity PROTO((tree, tree, int, int)); extern tree delete_sanity PROTO((tree, tree, int, int));
extern tree check_classfn PROTO((tree, tree)); extern tree check_classfn PROTO((tree, tree));
extern tree grokfield PROTO((tree, tree, tree, tree, tree, tree)); extern tree grokfield PROTO((tree, tree, tree, tree, tree));
extern tree grokbitfield PROTO((tree, tree, tree)); extern tree grokbitfield PROTO((tree, tree, tree));
extern tree groktypefield PROTO((tree, tree)); extern tree groktypefield PROTO((tree, tree));
extern tree grokoptypename PROTO((tree, tree)); extern tree grokoptypename PROTO((tree, tree));
...@@ -2192,6 +2207,8 @@ extern tree build_vec_delete PROTO((tree, tree, tree, tree, int)); ...@@ -2192,6 +2207,8 @@ extern tree build_vec_delete PROTO((tree, tree, tree, tree, int));
/* in lex.c */ /* in lex.c */
extern tree make_pointer_declarator PROTO((tree, tree)); extern tree make_pointer_declarator PROTO((tree, tree));
extern tree make_reference_declarator PROTO((tree, tree)); extern tree make_reference_declarator PROTO((tree, tree));
extern tree make_call_declarator PROTO((tree, tree, tree, tree));
extern void set_quals_and_spec PROTO((tree, tree, tree));
extern char *operator_name_string PROTO((tree)); extern char *operator_name_string PROTO((tree));
extern void lang_init PROTO((void)); extern void lang_init PROTO((void));
extern void lang_finish PROTO((void)); extern void lang_finish PROTO((void));
...@@ -2345,7 +2362,7 @@ extern tree get_template_base PROTO((tree, tree)); ...@@ -2345,7 +2362,7 @@ extern tree get_template_base PROTO((tree, tree));
extern tree build_signature_pointer_type PROTO((tree, int, int)); extern tree build_signature_pointer_type PROTO((tree, int, int));
extern tree build_signature_reference_type PROTO((tree, int, int)); extern tree build_signature_reference_type PROTO((tree, int, int));
extern tree build_signature_pointer_constructor PROTO((tree, tree)); extern tree build_signature_pointer_constructor PROTO((tree, tree));
extern tree build_signature_method_call PROTO((tree, tree, tree, tree)); extern tree build_signature_method_call PROTO((tree, tree));
extern tree build_optr_ref PROTO((tree)); extern tree build_optr_ref PROTO((tree));
extern tree build_sptr_ref PROTO((tree)); extern tree build_sptr_ref PROTO((tree));
extern void append_signature_fields PROTO((tree)); extern void append_signature_fields PROTO((tree));
......
...@@ -594,6 +594,11 @@ build_up_reference (type, arg, flags, checkconst) ...@@ -594,6 +594,11 @@ build_up_reference (type, arg, flags, checkconst)
TREE_REFERENCE_EXPR (rval) = 1; TREE_REFERENCE_EXPR (rval) = 1;
return rval; return rval;
case TARGET_EXPR:
TREE_ADDRESSABLE (targ) = 1;
put_var_into_stack (TREE_OPERAND (targ, 0));
break;
default: default:
break; break;
} }
...@@ -742,15 +747,14 @@ convert_to_reference (reftype, expr, convtype, flags, decl) ...@@ -742,15 +747,14 @@ convert_to_reference (reftype, expr, convtype, flags, decl)
ttr = cp_build_type_variant (TREE_TYPE (expr), r, v); ttr = cp_build_type_variant (TREE_TYPE (expr), r, v);
} }
if (! real_lvalue_p (expr) && if (! real_lvalue_p (expr) && ! TYPE_READONLY (ttl))
(decl == NULL_TREE || ! TYPE_READONLY (ttl)))
{ {
if (decl) if (decl)
/* Ensure semantics of [dcl.init.ref] */ /* Ensure semantics of [dcl.init.ref] */
cp_pedwarn ("initialization of non-const `%T' from rvalue `%T'", cp_pedwarn ("initialization of non-const reference `%#T' from rvalue `%T'",
reftype, intype); reftype, intype);
else else
cp_pedwarn ("conversion to `%T' from rvalue `%T'", cp_pedwarn ("conversion to non-const `%T' from rvalue `%T'",
reftype, intype); reftype, intype);
} }
else if (! (convtype & CONV_CONST)) else if (! (convtype & CONV_CONST))
......
...@@ -5700,7 +5700,7 @@ shadow_tag (declspecs) ...@@ -5700,7 +5700,7 @@ shadow_tag (declspecs)
if (TYPE_FIELDS (t)) if (TYPE_FIELDS (t))
{ {
tree decl = grokdeclarator (NULL_TREE, declspecs, NORMAL, 0, tree decl = grokdeclarator (NULL_TREE, declspecs, NORMAL, 0,
NULL_TREE, NULL_TREE); NULL_TREE);
finish_anon_union (decl); finish_anon_union (decl);
} }
} }
...@@ -5739,7 +5739,7 @@ groktypename (typename) ...@@ -5739,7 +5739,7 @@ groktypename (typename)
return typename; return typename;
return grokdeclarator (TREE_VALUE (typename), return grokdeclarator (TREE_VALUE (typename),
TREE_PURPOSE (typename), TREE_PURPOSE (typename),
TYPENAME, 0, NULL_TREE, NULL_TREE); TYPENAME, 0, NULL_TREE);
} }
/* Decode a declarator in an ordinary declaration or data definition. /* Decode a declarator in an ordinary declaration or data definition.
...@@ -5764,10 +5764,9 @@ int debug_temp_inits = 1; ...@@ -5764,10 +5764,9 @@ int debug_temp_inits = 1;
void start_decl_1 (); void start_decl_1 ();
tree tree
start_decl (declarator, declspecs, initialized, raises) start_decl (declarator, declspecs, initialized)
tree declarator, declspecs; tree declarator, declspecs;
int initialized; int initialized;
tree raises;
{ {
register tree decl; register tree decl;
register tree type, tem; register tree type, tem;
...@@ -5788,7 +5787,7 @@ start_decl (declarator, declspecs, initialized, raises) ...@@ -5788,7 +5787,7 @@ start_decl (declarator, declspecs, initialized, raises)
used_extern_spec = 1; used_extern_spec = 1;
} }
decl = grokdeclarator (declarator, declspecs, NORMAL, initialized, raises, decl = grokdeclarator (declarator, declspecs, NORMAL, initialized,
NULL_TREE); NULL_TREE);
if (decl == NULL_TREE || decl == void_type_node) if (decl == NULL_TREE || decl == void_type_node)
return NULL_TREE; return NULL_TREE;
...@@ -5923,7 +5922,7 @@ start_decl (declarator, declspecs, initialized, raises) ...@@ -5923,7 +5922,7 @@ start_decl (declarator, declspecs, initialized, raises)
DECL_VINDEX (decl) DECL_VINDEX (decl)
= build_min_nt (DECL_STMT, copy_to_permanent (declarator), = build_min_nt (DECL_STMT, copy_to_permanent (declarator),
copy_to_permanent (declspecs), copy_to_permanent (declspecs),
copy_to_permanent (raises), NULL_TREE); NULL_TREE);
} }
...@@ -6249,7 +6248,7 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags) ...@@ -6249,7 +6248,7 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags)
{ {
tree stmt = DECL_VINDEX (decl); tree stmt = DECL_VINDEX (decl);
DECL_VINDEX (decl) = NULL_TREE; DECL_VINDEX (decl) = NULL_TREE;
TREE_OPERAND (stmt, 3) = copy_to_permanent (init); TREE_OPERAND (stmt, 2) = copy_to_permanent (init);
add_tree (stmt); add_tree (stmt);
} }
...@@ -7111,8 +7110,8 @@ grokfndecl (ctype, type, declarator, virtualp, flags, quals, ...@@ -7111,8 +7110,8 @@ grokfndecl (ctype, type, declarator, virtualp, flags, quals,
if (raises) if (raises)
{ {
type = build_exception_variant (type, raises); type = build_exception_variant (type, raises);
raises = TYPE_RAISES_EXCEPTIONS (type);
} }
decl = build_lang_decl (FUNCTION_DECL, declarator, type); decl = build_lang_decl (FUNCTION_DECL, declarator, type);
/* propagate volatile out from type to decl */ /* propagate volatile out from type to decl */
if (TYPE_VOLATILE (type)) if (TYPE_VOLATILE (type))
...@@ -7447,12 +7446,12 @@ build_ptrmemfunc_type (type) ...@@ -7447,12 +7446,12 @@ build_ptrmemfunc_type (type)
enum return_types { return_normal, return_ctor, return_dtor, return_conversion }; enum return_types { return_normal, return_ctor, return_dtor, return_conversion };
tree tree
grokdeclarator (declarator, declspecs, decl_context, initialized, raises, attrlist) grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
tree declspecs; tree declspecs;
tree declarator; tree declarator;
enum decl_context decl_context; enum decl_context decl_context;
int initialized; int initialized;
tree raises, attrlist; tree attrlist;
{ {
RID_BIT_TYPE specbits; RID_BIT_TYPE specbits;
int nclasses = 0; int nclasses = 0;
...@@ -7489,6 +7488,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises, attrli ...@@ -7489,6 +7488,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises, attrli
tree ctor_return_type = NULL_TREE; tree ctor_return_type = NULL_TREE;
enum overload_flags flags = NO_SPECIAL; enum overload_flags flags = NO_SPECIAL;
tree quals = NULL_TREE; tree quals = NULL_TREE;
tree raises = NULL_TREE;
RIDBIT_RESET_ALL (specbits); RIDBIT_RESET_ALL (specbits);
if (decl_context == FUNCDEF) if (decl_context == FUNCDEF)
...@@ -7579,7 +7579,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises, attrli ...@@ -7579,7 +7579,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises, attrli
*next = TREE_OPERAND (decl, 0); *next = TREE_OPERAND (decl, 0);
init = TREE_OPERAND (decl, 1); init = TREE_OPERAND (decl, 1);
decl = start_decl (declarator, declspecs, 1, NULL_TREE); decl = start_decl (declarator, declspecs, 1);
finish_decl (decl, init, NULL_TREE); finish_decl (decl, init, NULL_TREE);
return 0; return 0;
} }
...@@ -7587,6 +7587,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises, attrli ...@@ -7587,6 +7587,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises, attrli
if (decl_context == FIELD && ctype == NULL_TREE) if (decl_context == FIELD && ctype == NULL_TREE)
ctype = current_class_type; ctype = current_class_type;
if (ctype if (ctype
&& TREE_OPERAND (decl, 0)
&& (TREE_CODE (TREE_OPERAND (decl, 0)) == TYPE_DECL && (TREE_CODE (TREE_OPERAND (decl, 0)) == TYPE_DECL
&& ((DECL_NAME (TREE_OPERAND (decl, 0)) && ((DECL_NAME (TREE_OPERAND (decl, 0))
== constructor_name_full (ctype)) == constructor_name_full (ctype))
...@@ -8529,6 +8530,9 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises, attrli ...@@ -8529,6 +8530,9 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises, attrli
/* Pick up type qualifiers which should be applied to `this'. */ /* Pick up type qualifiers which should be applied to `this'. */
quals = TREE_OPERAND (declarator, 2); quals = TREE_OPERAND (declarator, 2);
/* Pick up the exception specifications. */
raises = TREE_TYPE (declarator);
/* Say it's a definition only for the CALL_EXPR /* Say it's a definition only for the CALL_EXPR
closest to the identifier. */ closest to the identifier. */
funcdecl_p = funcdecl_p =
...@@ -9776,11 +9780,10 @@ grokparms (first_parm, funcdef_flag) ...@@ -9776,11 +9780,10 @@ grokparms (first_parm, funcdef_flag)
if (decl != void_type_node) if (decl != void_type_node)
{ {
/* @@ May need to fetch out a `raises' here. */
decl = grokdeclarator (TREE_VALUE (decl), decl = grokdeclarator (TREE_VALUE (decl),
TREE_PURPOSE (decl), TREE_PURPOSE (decl),
PARM, init != NULL_TREE, PARM, init != NULL_TREE,
NULL_TREE, NULL_TREE); NULL_TREE);
if (! decl) if (! decl)
continue; continue;
type = TREE_TYPE (decl); type = TREE_TYPE (decl);
...@@ -9878,7 +9881,7 @@ grokparms (first_parm, funcdef_flag) ...@@ -9878,7 +9881,7 @@ grokparms (first_parm, funcdef_flag)
else else
init = require_instantiated_type (type, init, integer_zero_node); init = require_instantiated_type (type, init, integer_zero_node);
if (! current_template_parms if (! current_template_parms
&& ! implicit_conversion (type, TREE_TYPE (init), init, LOOKUP_NORMAL)) && ! can_convert_arg (type, TREE_TYPE (init), init))
cp_pedwarn ("invalid type `%T' for default argument to `%#D'", cp_pedwarn ("invalid type `%T' for default argument to `%#D'",
TREE_TYPE (init), decl); TREE_TYPE (init), decl);
} }
...@@ -9933,6 +9936,21 @@ grokparms (first_parm, funcdef_flag) ...@@ -9933,6 +9936,21 @@ grokparms (first_parm, funcdef_flag)
return result; return result;
} }
int
copy_args_p (d)
tree d;
{
tree t = FUNCTION_ARG_CHAIN (d);
if (t && TREE_CODE (TREE_VALUE (t)) == REFERENCE_TYPE
&& (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_VALUE (t)))
== DECL_CLASS_CONTEXT (d))
&& (TREE_CHAIN (t) == NULL_TREE
|| TREE_CHAIN (t) == void_list_node
|| TREE_PURPOSE (TREE_CHAIN (t))))
return 1;
return 0;
}
/* These memoizing functions keep track of special properties which /* These memoizing functions keep track of special properties which
a class may have. `grok_ctor_properties' notices whether a class a class may have. `grok_ctor_properties' notices whether a class
has a constructor of the form X(X&), and also complains has a constructor of the form X(X&), and also complains
...@@ -10880,8 +10898,8 @@ static int function_depth; ...@@ -10880,8 +10898,8 @@ static int function_depth;
@@ something we had previously. */ @@ something we had previously. */
int int
start_function (declspecs, declarator, raises, attrs, pre_parsed_p) start_function (declspecs, declarator, attrs, pre_parsed_p)
tree declspecs, declarator, raises, attrs; tree declspecs, declarator, attrs;
int pre_parsed_p; int pre_parsed_p;
{ {
tree decl1; tree decl1;
...@@ -10957,8 +10975,6 @@ start_function (declspecs, declarator, raises, attrs, pre_parsed_p) ...@@ -10957,8 +10975,6 @@ start_function (declspecs, declarator, raises, attrs, pre_parsed_p)
doing_friend = 1; doing_friend = 1;
} }
raises = TYPE_RAISES_EXCEPTIONS (fntype);
/* In a fcn definition, arg types must be complete. */ /* In a fcn definition, arg types must be complete. */
require_complete_types_for_parms (DECL_ARGUMENTS (decl1)); require_complete_types_for_parms (DECL_ARGUMENTS (decl1));
...@@ -10975,8 +10991,7 @@ start_function (declspecs, declarator, raises, attrs, pre_parsed_p) ...@@ -10975,8 +10991,7 @@ start_function (declspecs, declarator, raises, attrs, pre_parsed_p)
} }
else else
{ {
decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, raises, decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, NULL_TREE);
NULL_TREE);
/* If the declarator is not suitable for a function definition, /* If the declarator is not suitable for a function definition,
cause a syntax error. */ cause a syntax error. */
if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL) return 0; if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL) return 0;
...@@ -12109,10 +12124,10 @@ finish_function (lineno, call_poplevel, nested) ...@@ -12109,10 +12124,10 @@ finish_function (lineno, call_poplevel, nested)
CHANGES TO CODE IN `grokfield'. */ CHANGES TO CODE IN `grokfield'. */
tree tree
start_method (declspecs, declarator, raises) start_method (declspecs, declarator)
tree declarator, declspecs, raises; tree declarator, declspecs;
{ {
tree fndecl = grokdeclarator (declarator, declspecs, MEMFUNCDEF, 0, raises, tree fndecl = grokdeclarator (declarator, declspecs, MEMFUNCDEF, 0,
NULL_TREE); NULL_TREE);
/* Something too ugly to handle. */ /* Something too ugly to handle. */
......
...@@ -31,7 +31,7 @@ enum decl_context ...@@ -31,7 +31,7 @@ enum decl_context
}; };
/* We need this in here to get the decl_context definition. */ /* We need this in here to get the decl_context definition. */
extern tree grokdeclarator PROTO((tree, tree, enum decl_context, int, tree, tree)); extern tree grokdeclarator PROTO((tree, tree, enum decl_context, int, tree));
/* C++: Keep these around to reduce calls to `get_identifier'. /* C++: Keep these around to reduce calls to `get_identifier'.
Identifiers for `this' in member functions and the auto-delete Identifiers for `this' in member functions and the auto-delete
......
...@@ -37,10 +37,6 @@ Boston, MA 02111-1307, USA. */ ...@@ -37,10 +37,6 @@ Boston, MA 02111-1307, USA. */
#include "lex.h" #include "lex.h"
#include "output.h" #include "output.h"
#ifndef SUPPORTS_ONE_ONLY
#define SUPPORTS_ONE_ONLY 0
#endif
extern tree get_file_function_name (); extern tree get_file_function_name ();
extern tree cleanups_this_call; extern tree cleanups_this_call;
static void grok_function_init PROTO((tree, tree)); static void grok_function_init PROTO((tree, tree));
...@@ -1339,8 +1335,8 @@ check_classfn (ctype, function) ...@@ -1339,8 +1335,8 @@ check_classfn (ctype, function)
CHANGES TO CODE IN `start_method'. */ CHANGES TO CODE IN `start_method'. */
tree tree
grokfield (declarator, declspecs, raises, init, asmspec_tree, attrlist) grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
tree declarator, declspecs, raises, init, asmspec_tree, attrlist; tree declarator, declspecs, init, asmspec_tree, attrlist;
{ {
register tree value; register tree value;
char *asmspec = 0; char *asmspec = 0;
...@@ -1376,8 +1372,7 @@ grokfield (declarator, declspecs, raises, init, asmspec_tree, attrlist) ...@@ -1376,8 +1372,7 @@ grokfield (declarator, declspecs, raises, init, asmspec_tree, attrlist)
&& TREE_CHAIN (init) == NULL_TREE) && TREE_CHAIN (init) == NULL_TREE)
init = NULL_TREE; init = NULL_TREE;
value = grokdeclarator (declarator, declspecs, FIELD, init != 0, value = grokdeclarator (declarator, declspecs, FIELD, init != 0, NULL_TREE);
raises, NULL_TREE);
if (! value) if (! value)
return value; /* friend or constructor went bad. */ return value; /* friend or constructor went bad. */
...@@ -1593,7 +1588,7 @@ grokbitfield (declarator, declspecs, width) ...@@ -1593,7 +1588,7 @@ grokbitfield (declarator, declspecs, width)
tree declarator, declspecs, width; tree declarator, declspecs, width;
{ {
register tree value = grokdeclarator (declarator, declspecs, BITFIELD, register tree value = grokdeclarator (declarator, declspecs, BITFIELD,
0, NULL_TREE, NULL_TREE); 0, NULL_TREE);
if (! value) return NULL_TREE; /* friends went bad. */ if (! value) return NULL_TREE; /* friends went bad. */
...@@ -1640,194 +1635,11 @@ grokbitfield (declarator, declspecs, width) ...@@ -1640,194 +1635,11 @@ grokbitfield (declarator, declspecs, width)
return value; return value;
} }
#if 0
/* Like GROKFIELD, except that the declarator has been
buried in DECLSPECS. Find the declarator, and
return something that looks like it came from
GROKFIELD. */
tree
groktypefield (declspecs, parmlist)
tree declspecs;
tree parmlist;
{
tree spec = declspecs;
tree prev = NULL_TREE;
tree type_id = NULL_TREE;
tree quals = NULL_TREE;
tree lengths = NULL_TREE;
tree decl = NULL_TREE;
while (spec)
{
register tree id = TREE_VALUE (spec);
if (TREE_CODE (spec) != TREE_LIST)
/* Certain parse errors slip through. For example,
`int class ();' is not caught by the parser. Try
weakly to recover here. */
return NULL_TREE;
if (TREE_CODE (id) == TYPE_DECL
|| (TREE_CODE (id) == IDENTIFIER_NODE && TREE_TYPE (id)))
{
/* We have a constructor/destructor or
conversion operator. Use it. */
if (prev)
TREE_CHAIN (prev) = TREE_CHAIN (spec);
else
declspecs = TREE_CHAIN (spec);
type_id = id;
goto found;
}
prev = spec;
spec = TREE_CHAIN (spec);
}
/* Nope, we have a conversion operator to a scalar type or something
else, that includes things like constructor declarations for
templates. */
spec = declspecs;
while (spec)
{
tree id = TREE_VALUE (spec);
if (TREE_CODE (id) == IDENTIFIER_NODE)
{
if (id == ridpointers[(int)RID_INT]
|| id == ridpointers[(int)RID_DOUBLE]
|| id == ridpointers[(int)RID_FLOAT]
|| id == ridpointers[(int)RID_WCHAR])
{
if (type_id)
error ("extra `%s' ignored",
IDENTIFIER_POINTER (id));
else
type_id = id;
}
else if (id == ridpointers[(int)RID_LONG]
|| id == ridpointers[(int)RID_SHORT]
|| id == ridpointers[(int)RID_CHAR])
{
lengths = tree_cons (NULL_TREE, id, lengths);
}
else if (id == ridpointers[(int)RID_VOID])
{
if (type_id)
error ("spurious `void' type ignored");
else
error ("conversion to `void' type invalid");
}
else if (id == ridpointers[(int)RID_AUTO]
|| id == ridpointers[(int)RID_REGISTER]
|| id == ridpointers[(int)RID_TYPEDEF]
|| id == ridpointers[(int)RID_CONST]
|| id == ridpointers[(int)RID_VOLATILE])
{
error ("type specifier `%s' used invalidly",
IDENTIFIER_POINTER (id));
}
else if (id == ridpointers[(int)RID_FRIEND]
|| id == ridpointers[(int)RID_VIRTUAL]
|| id == ridpointers[(int)RID_INLINE]
|| id == ridpointers[(int)RID_UNSIGNED]
|| id == ridpointers[(int)RID_SIGNED]
|| id == ridpointers[(int)RID_STATIC]
|| id == ridpointers[(int)RID_EXTERN])
{
quals = tree_cons (NULL_TREE, id, quals);
}
else
{
/* Happens when we have a global typedef
and a class-local member function with
the same name. */
type_id = id;
goto found;
}
}
else if (TREE_CODE (id) == RECORD_TYPE)
{
type_id = TYPE_NAME (id);
if (TREE_CODE (type_id) == TYPE_DECL)
type_id = DECL_NAME (type_id);
if (type_id == NULL_TREE)
error ("identifier for aggregate type conversion omitted");
}
else if (TREE_CODE_CLASS (TREE_CODE (id)) == 't')
error ("`operator' missing on conversion operator or tag missing from type");
else
my_friendly_abort (194);
spec = TREE_CHAIN (spec);
}
if (type_id)
declspecs = chainon (lengths, quals);
else if (lengths)
{
if (TREE_CHAIN (lengths))
error ("multiple length specifiers");
type_id = ridpointers[(int)RID_INT];
declspecs = chainon (lengths, quals);
}
else if (quals)
{
error ("no type given, defaulting to `operator int ...'");
type_id = ridpointers[(int)RID_INT];
declspecs = quals;
}
else
return NULL_TREE;
found:
decl = grokdeclarator (build_parse_node (CALL_EXPR, type_id, parmlist, NULL_TREE),
declspecs, FIELD, 0, NULL_TREE, NULL_TREE);
if (decl == NULL_TREE)
return NULL_TREE;
if (TREE_CODE (decl) == FUNCTION_DECL && DECL_CHAIN (decl) != NULL_TREE)
{
/* Need a fresh node here so that we don't get circularity
when we link these together. */
decl = copy_node (decl);
}
if (decl == void_type_node
|| (TREE_CODE (decl) == FUNCTION_DECL
&& TREE_CODE (TREE_TYPE (decl)) != METHOD_TYPE))
/* bunch of friends. */
return decl;
if (DECL_IN_AGGR_P (decl))
{
cp_error ("`%D' already defined in the class ", decl);
return void_type_node;
}
cp_finish_decl (decl, NULL_TREE, NULL_TREE, 0, 0);
/* If this declaration is common to another declaration
complain about such redundancy, and return NULL_TREE
so that we don't build a circular list. */
if (DECL_CHAIN (decl))
{
cp_error ("function `%D' declared twice in class %T", decl,
DECL_CONTEXT (decl));
return NULL_TREE;
}
DECL_IN_AGGR_P (decl) = 1;
return decl;
}
#endif
tree tree
grokoptypename (declspecs, declarator) grokoptypename (declspecs, declarator)
tree declspecs, declarator; tree declspecs, declarator;
{ {
tree t = grokdeclarator (declarator, declspecs, TYPENAME, 0, tree t = grokdeclarator (declarator, declspecs, TYPENAME, 0, NULL_TREE);
NULL_TREE, NULL_TREE);
return build_typename_overload (t); return build_typename_overload (t);
} }
...@@ -2486,12 +2298,9 @@ comdat_linkage (decl) ...@@ -2486,12 +2298,9 @@ comdat_linkage (decl)
{ {
TREE_PUBLIC (decl) = 0; TREE_PUBLIC (decl) = 0;
#ifdef DECL_ONE_ONLY #ifdef MAKE_DECL_ONE_ONLY
if (SUPPORTS_ONE_ONLY) MAKE_DECL_ONE_ONLY (decl);
{
DECL_ONE_ONLY (decl) = 1;
TREE_PUBLIC (decl) = 1; TREE_PUBLIC (decl) = 1;
}
#endif #endif
if (flag_weak) if (flag_weak)
...@@ -2499,7 +2308,6 @@ comdat_linkage (decl) ...@@ -2499,7 +2308,6 @@ comdat_linkage (decl)
DECL_WEAK (decl) = 1; DECL_WEAK (decl) = 1;
TREE_PUBLIC (decl) = 1; TREE_PUBLIC (decl) = 1;
} }
} }
/* Set TREE_PUBLIC and/or DECL_EXTERN on the vtable DECL, /* Set TREE_PUBLIC and/or DECL_EXTERN on the vtable DECL,
...@@ -2585,8 +2393,8 @@ finish_prevtable_vardecl (prev, vars) ...@@ -2585,8 +2393,8 @@ finish_prevtable_vardecl (prev, vars)
tree ctype = DECL_CONTEXT (vars); tree ctype = DECL_CONTEXT (vars);
import_export_template (ctype); import_export_template (ctype);
#ifndef NO_LINKAGE_HEURISTICS
if (CLASSTYPE_INTERFACE_UNKNOWN (ctype) && TYPE_VIRTUAL_P (ctype) if (CLASSTYPE_INTERFACE_UNKNOWN (ctype) && TYPE_VIRTUAL_P (ctype)
&& ! (SUPPORTS_ONE_ONLY > 1)
&& ! CLASSTYPE_TEMPLATE_INSTANTIATION (ctype)) && ! CLASSTYPE_TEMPLATE_INSTANTIATION (ctype))
{ {
tree method; tree method;
...@@ -2604,6 +2412,7 @@ finish_prevtable_vardecl (prev, vars) ...@@ -2604,6 +2412,7 @@ finish_prevtable_vardecl (prev, vars)
} }
} }
} }
#endif
import_export_vtable (vars, ctype, 1); import_export_vtable (vars, ctype, 1);
return 1; return 1;
...@@ -2785,9 +2594,8 @@ import_export_decl (decl) ...@@ -2785,9 +2594,8 @@ import_export_decl (decl)
{ {
/* Statically initialized vars are weak or comdat, if /* Statically initialized vars are weak or comdat, if
supported. */ supported. */
#ifdef DECL_ONE_ONLY #ifdef MAKE_DECL_ONE_ONLY
if (SUPPORTS_ONE_ONLY) MAKE_DECL_ONE_ONLY (decl);
DECL_ONE_ONLY (decl) = 1;
#endif #endif
if (flag_weak) if (flag_weak)
DECL_WEAK (decl) = 1; DECL_WEAK (decl) = 1;
...@@ -2991,6 +2799,9 @@ finish_file () ...@@ -2991,6 +2799,9 @@ finish_file ()
} }
} }
for (vars = static_aggregates; vars; vars = TREE_CHAIN (vars))
if (! TREE_ASM_WRITTEN (TREE_VALUE (vars)))
rest_of_decl_compilation (TREE_VALUE (vars), 0, 1, 1);
vars = static_aggregates; vars = static_aggregates;
if (static_ctors || vars || exception_table_p ()) if (static_ctors || vars || exception_table_p ())
...@@ -3017,9 +2828,9 @@ finish_file () ...@@ -3017,9 +2828,9 @@ finish_file ()
fnname = get_file_function_name ('D'); fnname = get_file_function_name ('D');
start_function (void_list_node, start_function (void_list_node,
build_parse_node (CALL_EXPR, fnname, void_list_node, make_call_declarator (fnname, void_list_node, NULL_TREE,
NULL_TREE), NULL_TREE),
NULL_TREE, NULL_TREE, 0); NULL_TREE, 0);
fnname = DECL_ASSEMBLER_NAME (current_function_decl); fnname = DECL_ASSEMBLER_NAME (current_function_decl);
store_parm_decls (); store_parm_decls ();
...@@ -3083,9 +2894,9 @@ finish_file () ...@@ -3083,9 +2894,9 @@ finish_file ()
{ {
fnname = get_file_function_name ('I'); fnname = get_file_function_name ('I');
start_function (void_list_node, start_function (void_list_node,
build_parse_node (CALL_EXPR, fnname, make_call_declarator (fnname, void_list_node, NULL_TREE,
void_list_node, NULL_TREE), NULL_TREE),
NULL_TREE, NULL_TREE, 0); NULL_TREE, 0);
fnname = DECL_ASSEMBLER_NAME (current_function_decl); fnname = DECL_ASSEMBLER_NAME (current_function_decl);
store_parm_decls (); store_parm_decls ();
......
...@@ -312,36 +312,36 @@ init_exception_processing () ...@@ -312,36 +312,36 @@ init_exception_processing ()
declspecs = tree_cons (NULL_TREE, get_identifier ("void"), NULL_TREE); declspecs = tree_cons (NULL_TREE, get_identifier ("void"), NULL_TREE);
d = build_parse_node (INDIRECT_REF, get_identifier ("__eh_pc")); d = build_parse_node (INDIRECT_REF, get_identifier ("__eh_pc"));
d = start_decl (d, declspecs, 0, NULL_TREE); d = start_decl (d, declspecs, 0);
DECL_COMMON (d) = 1; DECL_COMMON (d) = 1;
cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0); cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0);
saved_pc = lookup_name (get_identifier ("__eh_pc"), 0); saved_pc = lookup_name (get_identifier ("__eh_pc"), 0);
declspecs = tree_cons (NULL_TREE, get_identifier ("void"), NULL_TREE); declspecs = tree_cons (NULL_TREE, get_identifier ("void"), NULL_TREE);
d = build_parse_node (INDIRECT_REF, get_identifier ("__eh_type")); d = build_parse_node (INDIRECT_REF, get_identifier ("__eh_type"));
d = start_decl (d, declspecs, 0, NULL_TREE); d = start_decl (d, declspecs, 0);
DECL_COMMON (d) = 1; DECL_COMMON (d) = 1;
cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0); cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0);
saved_throw_type = lookup_name (get_identifier ("__eh_type"), 0); saved_throw_type = lookup_name (get_identifier ("__eh_type"), 0);
declspecs = tree_cons (NULL_TREE, get_identifier ("void"), NULL_TREE); declspecs = tree_cons (NULL_TREE, get_identifier ("void"), NULL_TREE);
d = build_parse_node (INDIRECT_REF, get_identifier ("__eh_value")); d = build_parse_node (INDIRECT_REF, get_identifier ("__eh_value"));
d = start_decl (d, declspecs, 0, NULL_TREE); d = start_decl (d, declspecs, 0);
DECL_COMMON (d) = 1; DECL_COMMON (d) = 1;
cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0); cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0);
saved_throw_value = lookup_name (get_identifier ("__eh_value"), 0); saved_throw_value = lookup_name (get_identifier ("__eh_value"), 0);
declspecs = tree_cons (NULL_TREE, get_identifier ("void"), NULL_TREE); declspecs = tree_cons (NULL_TREE, get_identifier ("void"), NULL_TREE);
d = build_parse_node (INDIRECT_REF, get_identifier ("__eh_cleanup")); d = build_parse_node (INDIRECT_REF, get_identifier ("__eh_cleanup"));
d = build_parse_node (CALL_EXPR, d, void_list_node, NULL_TREE); d = make_call_declarator (d, void_list_node, NULL_TREE, NULL_TREE);
d = start_decl (d, declspecs, 0, NULL_TREE); d = start_decl (d, declspecs, 0);
DECL_COMMON (d) = 1; DECL_COMMON (d) = 1;
cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0); cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0);
saved_cleanup = lookup_name (get_identifier ("__eh_cleanup"), 0); saved_cleanup = lookup_name (get_identifier ("__eh_cleanup"), 0);
declspecs = tree_cons (NULL_TREE, get_identifier ("bool"), NULL_TREE); declspecs = tree_cons (NULL_TREE, get_identifier ("bool"), NULL_TREE);
d = get_identifier ("__eh_in_catch"); d = get_identifier ("__eh_in_catch");
d = start_decl (d, declspecs, 0, NULL_TREE); d = start_decl (d, declspecs, 0);
DECL_COMMON (d) = 1; DECL_COMMON (d) = 1;
cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0); cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0);
saved_in_catch = lookup_name (get_identifier ("__eh_in_catch"), 0); saved_in_catch = lookup_name (get_identifier ("__eh_in_catch"), 0);
...@@ -429,6 +429,7 @@ expand_start_catch_block (declspecs, declarator) ...@@ -429,6 +429,7 @@ expand_start_catch_block (declspecs, declarator)
return; return;
/* Create a binding level for the parm. */ /* Create a binding level for the parm. */
pushlevel (0);
expand_start_bindings (0); expand_start_bindings (0);
false_label_rtx = gen_label_rtx (); false_label_rtx = gen_label_rtx ();
...@@ -440,8 +441,7 @@ expand_start_catch_block (declspecs, declarator) ...@@ -440,8 +441,7 @@ expand_start_catch_block (declspecs, declarator)
rtx call_rtx, return_value_rtx; rtx call_rtx, return_value_rtx;
tree init_type; tree init_type;
decl = grokdeclarator (declarator, declspecs, CATCHPARM, 1, decl = grokdeclarator (declarator, declspecs, CATCHPARM, 1, NULL_TREE);
NULL_TREE, NULL_TREE);
if (decl == NULL_TREE) if (decl == NULL_TREE)
{ {
...@@ -545,8 +545,8 @@ void expand_end_catch_block () ...@@ -545,8 +545,8 @@ void expand_end_catch_block ()
expand_leftover_cleanups (); expand_leftover_cleanups ();
/* Cleanup the EH parameter. */ /* Cleanup the EH parameter. */
decls = getdecls (); expand_end_bindings (getdecls (), kept_level_p (), 0);
expand_end_bindings (decls, decls != NULL_TREE, 0); poplevel (kept_level_p (), 1, 0);
/* label we emit to jump to if this catch block didn't match. */ /* label we emit to jump to if this catch block didn't match. */
/* This the closing } in the `if (eq) {' of the documentation. */ /* This the closing } in the `if (eq) {' of the documentation. */
...@@ -671,10 +671,11 @@ expand_builtin_throw () ...@@ -671,10 +671,11 @@ expand_builtin_throw ()
return; return;
params = void_list_node; params = void_list_node;
t = build_parse_node (CALL_EXPR, get_identifier ("__throw"), params, NULL_TREE); t = make_call_declarator (get_identifier ("__throw"), params, NULL_TREE,
NULL_TREE);
start_function (decl_tree_cons (NULL_TREE, get_identifier ("static"), start_function (decl_tree_cons (NULL_TREE, get_identifier ("static"),
void_list_node), void_list_node),
t, NULL_TREE, NULL_TREE, 0); t, NULL_TREE, 0);
store_parm_decls (); store_parm_decls ();
pushlevel (0); pushlevel (0);
clear_last_expr (); clear_last_expr ();
...@@ -868,7 +869,7 @@ void ...@@ -868,7 +869,7 @@ void
expand_exception_blocks () expand_exception_blocks ()
{ {
rtx funcend; rtx funcend;
rtx insns; rtx insn, insns;
rtx eh_spec_insns = NULL_RTX; rtx eh_spec_insns = NULL_RTX;
start_sequence (); start_sequence ();
...@@ -957,7 +958,14 @@ expand_exception_blocks () ...@@ -957,7 +958,14 @@ expand_exception_blocks ()
store_after_parms (eh_spec_insns); store_after_parms (eh_spec_insns);
#endif #endif
emit_insns (insns); insn = get_last_insn ();
while (GET_CODE (insn) == NOTE
|| (GET_CODE (insn) == INSN
&& (GET_CODE (PATTERN (insn)) == USE
|| GET_CODE (PATTERN (insn)) == CLOBBER)))
insn = PREV_INSN (insn);
emit_insns_after (insns, insn);
} }
tree tree
...@@ -980,10 +988,11 @@ start_anon_func () ...@@ -980,10 +988,11 @@ start_anon_func ()
params = void_list_node; params = void_list_node;
/* tcf stands for throw clean funciton. */ /* tcf stands for throw clean funciton. */
sprintf (name, "__tcf_%d", counter++); sprintf (name, "__tcf_%d", counter++);
t = build_parse_node (CALL_EXPR, get_identifier (name), params, NULL_TREE); t = make_call_declarator (get_identifier (name), params, NULL_TREE,
NULL_TREE);
start_function (decl_tree_cons (NULL_TREE, get_identifier ("static"), start_function (decl_tree_cons (NULL_TREE, get_identifier ("static"),
void_list_node), void_list_node),
t, NULL_TREE, NULL_TREE, 0); t, NULL_TREE, 0);
store_parm_decls (); store_parm_decls ();
pushlevel (0); pushlevel (0);
clear_last_expr (); clear_last_expr ();
......
...@@ -9,8 +9,8 @@ __asm, GCC_ASM_KEYWORD, NORID ...@@ -9,8 +9,8 @@ __asm, GCC_ASM_KEYWORD, NORID
__asm__, GCC_ASM_KEYWORD, NORID __asm__, GCC_ASM_KEYWORD, NORID
__attribute, ATTRIBUTE, NORID __attribute, ATTRIBUTE, NORID
__attribute__, ATTRIBUTE, NORID __attribute__, ATTRIBUTE, NORID
__const, TYPE_QUAL, RID_CONST __const, CV_QUALIFIER, RID_CONST
__const__, TYPE_QUAL, RID_CONST __const__, CV_QUALIFIER, RID_CONST
__extension__, EXTENSION, NORID __extension__, EXTENSION, NORID
__inline, SCSPEC, RID_INLINE __inline, SCSPEC, RID_INLINE
__inline__, SCSPEC, RID_INLINE __inline__, SCSPEC, RID_INLINE
...@@ -22,8 +22,8 @@ __signed__, TYPESPEC, RID_SIGNED ...@@ -22,8 +22,8 @@ __signed__, TYPESPEC, RID_SIGNED
__sigof__, SIGOF, NORID /* Extension */, __sigof__, SIGOF, NORID /* Extension */,
__typeof, TYPEOF, NORID __typeof, TYPEOF, NORID
__typeof__, TYPEOF, NORID __typeof__, TYPEOF, NORID
__volatile, TYPE_QUAL, RID_VOLATILE __volatile, CV_QUALIFIER, RID_VOLATILE
__volatile__, TYPE_QUAL, RID_VOLATILE __volatile__, CV_QUALIFIER, RID_VOLATILE
__wchar_t, TYPESPEC, RID_WCHAR /* Unique to ANSI C++ */, __wchar_t, TYPESPEC, RID_WCHAR /* Unique to ANSI C++ */,
asm, ASM_KEYWORD, NORID, asm, ASM_KEYWORD, NORID,
and, ANDAND, NORID, and, ANDAND, NORID,
...@@ -38,7 +38,7 @@ catch, CATCH, NORID, ...@@ -38,7 +38,7 @@ catch, CATCH, NORID,
char, TYPESPEC, RID_CHAR, char, TYPESPEC, RID_CHAR,
class, AGGR, RID_CLASS, class, AGGR, RID_CLASS,
compl, '~', NORID, compl, '~', NORID,
const, TYPE_QUAL, RID_CONST, const, CV_QUALIFIER, RID_CONST,
const_cast, CONST_CAST, NORID, const_cast, CONST_CAST, NORID,
continue, CONTINUE, NORID, continue, CONTINUE, NORID,
default, DEFAULT, NORID, default, DEFAULT, NORID,
...@@ -97,7 +97,7 @@ unsigned, TYPESPEC, RID_UNSIGNED, ...@@ -97,7 +97,7 @@ unsigned, TYPESPEC, RID_UNSIGNED,
using, USING, NORID, using, USING, NORID,
virtual, SCSPEC, RID_VIRTUAL, virtual, SCSPEC, RID_VIRTUAL,
void, TYPESPEC, RID_VOID, void, TYPESPEC, RID_VOID,
volatile, TYPE_QUAL, RID_VOLATILE, volatile, CV_QUALIFIER, RID_VOLATILE,
while, WHILE, NORID, while, WHILE, NORID,
xor, '^', NORID, xor, '^', NORID,
xor_eq, ASSIGN, NORID, xor_eq, ASSIGN, NORID,
/* C code produced by gperf version 2.5 (GNU C++ version) */ /* C code produced by gperf version 2.5 (GNU C++ version) */
/* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,7,$ /yorick/splunge/jason/g++/small/devo/gcc/cp/gxx.gperf */ /* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,7,$ ../../../devo/gcc/cp/gxx.gperf */
/* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,$,7 gplus.gperf */ /* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,$,7 gplus.gperf */
struct resword { char *name; short token; enum rid rid;}; struct resword { char *name; short token; enum rid rid;};
...@@ -123,7 +123,7 @@ is_reserved_word (str, len) ...@@ -123,7 +123,7 @@ is_reserved_word (str, len)
{"mutable", SCSPEC, RID_MUTABLE,}, {"mutable", SCSPEC, RID_MUTABLE,},
{"short", TYPESPEC, RID_SHORT,}, {"short", TYPESPEC, RID_SHORT,},
{"signature", AGGR, RID_SIGNATURE /* Extension */,}, {"signature", AGGR, RID_SIGNATURE /* Extension */,},
{"const", TYPE_QUAL, RID_CONST,}, {"const", CV_QUALIFIER, RID_CONST,},
{"static", SCSPEC, RID_STATIC,}, {"static", SCSPEC, RID_STATIC,},
{"",}, {"",}, {"",}, {"",},
{"for", FOR, NORID,}, {"for", FOR, NORID,},
...@@ -149,11 +149,11 @@ is_reserved_word (str, len) ...@@ -149,11 +149,11 @@ is_reserved_word (str, len)
{"",}, {"",}, {"",}, {"",}, {"",}, {"",},
{"signed", TYPESPEC, RID_SIGNED,}, {"signed", TYPESPEC, RID_SIGNED,},
{"this", THIS, NORID,}, {"this", THIS, NORID,},
{"__const", TYPE_QUAL, RID_CONST}, {"__const", CV_QUALIFIER, RID_CONST},
{"__const__", TYPE_QUAL, RID_CONST}, {"__const__", CV_QUALIFIER, RID_CONST},
{"__volatile", TYPE_QUAL, RID_VOLATILE}, {"__volatile", CV_QUALIFIER, RID_VOLATILE},
{"__null", CONSTANT, RID_NULL}, {"__null", CONSTANT, RID_NULL},
{"__volatile__", TYPE_QUAL, RID_VOLATILE}, {"__volatile__", CV_QUALIFIER, RID_VOLATILE},
{"__typeof__", TYPEOF, NORID}, {"__typeof__", TYPEOF, NORID},
{"or_eq", ASSIGN, NORID,}, {"or_eq", ASSIGN, NORID,},
{"",}, {"",},
...@@ -178,7 +178,7 @@ is_reserved_word (str, len) ...@@ -178,7 +178,7 @@ is_reserved_word (str, len)
{"bitor", '|', NORID,}, {"bitor", '|', NORID,},
{"",}, {"",},
{"do", DO, NORID,}, {"do", DO, NORID,},
{"volatile", TYPE_QUAL, RID_VOLATILE,}, {"volatile", CV_QUALIFIER, RID_VOLATILE,},
{"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
{"if", IF, NORID,}, {"if", IF, NORID,},
{"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
......
...@@ -131,35 +131,35 @@ extern int *token_count; ...@@ -131,35 +131,35 @@ extern int *token_count;
/* Return something to represent absolute declarators containing a *. /* Return something to represent absolute declarators containing a *.
TARGET is the absolute declarator that the * contains. TARGET is the absolute declarator that the * contains.
TYPE_QUALS is a list of modifiers such as const or volatile CV_QUALIFIERS is a list of modifiers such as const or volatile
to apply to the pointer type, represented as identifiers. to apply to the pointer type, represented as identifiers.
We return an INDIRECT_REF whose "contents" are TARGET We return an INDIRECT_REF whose "contents" are TARGET
and whose type is the modifier list. */ and whose type is the modifier list. */
tree tree
make_pointer_declarator (type_quals, target) make_pointer_declarator (cv_qualifiers, target)
tree type_quals, target; tree cv_qualifiers, target;
{ {
if (target && TREE_CODE (target) == IDENTIFIER_NODE if (target && TREE_CODE (target) == IDENTIFIER_NODE
&& ANON_AGGRNAME_P (target)) && ANON_AGGRNAME_P (target))
error ("type name expected before `*'"); error ("type name expected before `*'");
target = build_parse_node (INDIRECT_REF, target); target = build_parse_node (INDIRECT_REF, target);
TREE_TYPE (target) = type_quals; TREE_TYPE (target) = cv_qualifiers;
return target; return target;
} }
/* Return something to represent absolute declarators containing a &. /* Return something to represent absolute declarators containing a &.
TARGET is the absolute declarator that the & contains. TARGET is the absolute declarator that the & contains.
TYPE_QUALS is a list of modifiers such as const or volatile CV_QUALIFIERS is a list of modifiers such as const or volatile
to apply to the reference type, represented as identifiers. to apply to the reference type, represented as identifiers.
We return an ADDR_EXPR whose "contents" are TARGET We return an ADDR_EXPR whose "contents" are TARGET
and whose type is the modifier list. */ and whose type is the modifier list. */
tree tree
make_reference_declarator (type_quals, target) make_reference_declarator (cv_qualifiers, target)
tree type_quals, target; tree cv_qualifiers, target;
{ {
if (target) if (target)
{ {
...@@ -177,10 +177,27 @@ make_reference_declarator (type_quals, target) ...@@ -177,10 +177,27 @@ make_reference_declarator (type_quals, target)
error ("type name expected before `&'"); error ("type name expected before `&'");
} }
target = build_parse_node (ADDR_EXPR, target); target = build_parse_node (ADDR_EXPR, target);
TREE_TYPE (target) = type_quals; TREE_TYPE (target) = cv_qualifiers;
return target; return target;
} }
tree
make_call_declarator (target, parms, cv_qualifiers, exception_specification)
tree target, parms, cv_qualifiers, exception_specification;
{
target = build_parse_node (CALL_EXPR, target, parms, cv_qualifiers);
TREE_TYPE (target) = exception_specification;
return target;
}
void
set_quals_and_spec (call_declarator, cv_qualifiers, exception_specification)
tree call_declarator, cv_qualifiers, exception_specification;
{
TREE_OPERAND (call_declarator, 2) = cv_qualifiers;
TREE_TYPE (call_declarator) = exception_specification;
}
/* Build names and nodes for overloaded operators. */ /* Build names and nodes for overloaded operators. */
tree ansi_opname[LAST_CPLUS_TREE_CODE]; tree ansi_opname[LAST_CPLUS_TREE_CODE];
...@@ -1681,12 +1698,11 @@ cons_up_default_function (type, full_name, kind) ...@@ -1681,12 +1698,11 @@ cons_up_default_function (type, full_name, kind)
TREE_PARMLIST (args) = 1; TREE_PARMLIST (args) = 1;
{ {
tree declarator = build_parse_node (CALL_EXPR, name, args, NULL_TREE); tree declarator = make_call_declarator (name, args, NULL_TREE, NULL_TREE);
if (retref) if (retref)
declarator = build_parse_node (ADDR_EXPR, declarator); declarator = build_parse_node (ADDR_EXPR, declarator);
fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE, fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE, NULL_TREE);
NULL_TREE, NULL_TREE);
} }
if (fn == void_type_node) if (fn == void_type_node)
...@@ -2444,20 +2460,6 @@ readescape (ignore_ptr) ...@@ -2444,20 +2460,6 @@ readescape (ignore_ptr)
Value is 0 if we treat this name in a default fashion. */ Value is 0 if we treat this name in a default fashion. */
int looking_for_typename = 0; int looking_for_typename = 0;
#if 0
/* NO LONGER USED: Value is -1 if we must not see a type name. */
void
dont_see_typename ()
{
looking_for_typename = -1;
if (yychar == TYPENAME || yychar == PTYPENAME)
{
yychar = IDENTIFIER;
lastiddecl = 0;
}
}
#endif
#ifdef __GNUC__ #ifdef __GNUC__
extern __inline int identifier_type (); extern __inline int identifier_type ();
__inline __inline
...@@ -4363,11 +4365,6 @@ handle_cp_pragma (pname) ...@@ -4363,11 +4365,6 @@ handle_cp_pragma (pname)
main_filename = TREE_STRING_POINTER (yylval.ttype); main_filename = TREE_STRING_POINTER (yylval.ttype);
} }
#ifdef SUPPORTS_ONE_ONLY
if (SUPPORTS_ONE_ONLY > 1)
return 1;
#endif
while (token != END_OF_LINE) while (token != END_OF_LINE)
{ {
if (!warned_already && extra_warnings) if (!warned_already && extra_warnings)
...@@ -4378,6 +4375,7 @@ handle_cp_pragma (pname) ...@@ -4378,6 +4375,7 @@ handle_cp_pragma (pname)
token = real_yylex (); token = real_yylex ();
} }
#ifndef NO_LINKAGE_HEURISTICS
write_virtuals = 3; write_virtuals = 3;
if (impl_file_chain == 0) if (impl_file_chain == 0)
...@@ -4404,6 +4402,7 @@ handle_cp_pragma (pname) ...@@ -4404,6 +4402,7 @@ handle_cp_pragma (pname)
interface_unknown = 0; interface_unknown = 0;
TREE_INT_CST_LOW (fileinfo) = interface_only; TREE_INT_CST_LOW (fileinfo) = interface_only;
TREE_INT_CST_HIGH (fileinfo) = interface_unknown; TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
#endif /* NO_LINKAGE_HEURISTICS */
return 1; return 1;
} }
...@@ -4436,11 +4435,7 @@ handle_cp_pragma (pname) ...@@ -4436,11 +4435,7 @@ handle_cp_pragma (pname)
token = real_yylex (); token = real_yylex ();
} }
#ifdef SUPPORTS_ONE_ONLY #ifndef NO_LINKAGE_HEURISTICS
if (SUPPORTS_ONE_ONLY > 1)
return 1;
#endif
if (write_virtuals == 3) if (write_virtuals == 3)
{ {
struct impl_files *ifiles = impl_file_chain; struct impl_files *ifiles = impl_file_chain;
...@@ -4485,6 +4480,8 @@ handle_cp_pragma (pname) ...@@ -4485,6 +4480,8 @@ handle_cp_pragma (pname)
#endif #endif
TREE_INT_CST_LOW (fileinfo) = interface_only; TREE_INT_CST_LOW (fileinfo) = interface_only;
TREE_INT_CST_HIGH (fileinfo) = interface_unknown; TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
#endif /* NO_LINKAGE_HEURISTICS */
return 1; return 1;
} }
......
...@@ -39,10 +39,6 @@ Boston, MA 02111-1307, USA. */ ...@@ -39,10 +39,6 @@ Boston, MA 02111-1307, USA. */
#include "hard-reg-set.h" #include "hard-reg-set.h"
#include "flags.h" #include "flags.h"
#ifndef SUPPORTS_ONE_ONLY
#define SUPPORTS_ONE_ONLY 0
#endif
/* TREE_LIST of the current inline functions that need to be /* TREE_LIST of the current inline functions that need to be
processed. */ processed. */
struct pending_inline *pending_inlines; struct pending_inline *pending_inlines;
...@@ -2179,7 +2175,7 @@ synthesize_method (fndecl) ...@@ -2179,7 +2175,7 @@ synthesize_method (fndecl)
push_cp_function_context (context); push_cp_function_context (context);
interface_unknown = 1; interface_unknown = 1;
start_function (NULL_TREE, fndecl, NULL_TREE, NULL_TREE, 1); start_function (NULL_TREE, fndecl, NULL_TREE, 1);
store_parm_decls (); store_parm_decls ();
if (DECL_NAME (fndecl) == ansi_opname[MODIFY_EXPR]) if (DECL_NAME (fndecl) == ansi_opname[MODIFY_EXPR])
......
...@@ -121,7 +121,7 @@ empty_parms () ...@@ -121,7 +121,7 @@ empty_parms ()
/* Reserved words that qualify type: "const" or "volatile". /* Reserved words that qualify type: "const" or "volatile".
yylval contains an IDENTIFIER_NODE which indicates which one. */ yylval contains an IDENTIFIER_NODE which indicates which one. */
%token TYPE_QUAL %token CV_QUALIFIER
/* Character or numeric constants. /* Character or numeric constants.
yylval is the node for the constant. */ yylval is the node for the constant. */
...@@ -162,7 +162,7 @@ empty_parms () ...@@ -162,7 +162,7 @@ empty_parms ()
%nonassoc IF %nonassoc IF
%nonassoc ELSE %nonassoc ELSE
%left IDENTIFIER TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC TYPE_QUAL ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD %left IDENTIFIER TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
%left '{' ',' ';' %left '{' ',' ';'
...@@ -198,7 +198,7 @@ empty_parms () ...@@ -198,7 +198,7 @@ empty_parms ()
%type <ttype> reserved_declspecs boolean.literal %type <ttype> reserved_declspecs boolean.literal
%type <ttype> reserved_typespecquals %type <ttype> reserved_typespecquals
%type <ttype> declmods %type <ttype> declmods
%type <ttype> SCSPEC TYPESPEC TYPE_QUAL maybe_type_qual %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
%type <itype> initdecls notype_initdecls initdcl /* C++ modification */ %type <itype> initdecls notype_initdecls initdcl /* C++ modification */
%type <ttype> init initlist maybeasm maybe_init %type <ttype> init initlist maybeasm maybe_init
%type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
...@@ -216,7 +216,7 @@ empty_parms () ...@@ -216,7 +216,7 @@ empty_parms ()
%type <ttype> notype_component_declarator notype_component_declarator0 %type <ttype> notype_component_declarator notype_component_declarator0
%type <ttype> after_type_component_declarator after_type_component_declarator0 %type <ttype> after_type_component_declarator after_type_component_declarator0
%type <ttype> enumlist enumerator %type <ttype> enumlist enumerator
%type <ttype> absdcl type_quals %type <ttype> absdcl cv_qualifiers
%type <ttype> direct_abstract_declarator conversion_declarator %type <ttype> direct_abstract_declarator conversion_declarator
%type <ttype> new_declarator direct_new_declarator %type <ttype> new_declarator direct_new_declarator
%type <ttype> xexpr parmlist parms bad_parm %type <ttype> xexpr parmlist parms bad_parm
...@@ -229,7 +229,7 @@ empty_parms () ...@@ -229,7 +229,7 @@ empty_parms ()
%type <ttype> complex_parmlist parms_comma %type <ttype> complex_parmlist parms_comma
%type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
%type <ftype> typed_declspecs1 type_specifier_seq nonempty_type_quals %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
%type <ftype> structsp typespecqual_reserved parm named_parm full_parm %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
/* C++ extensions */ /* C++ extensions */
...@@ -256,7 +256,6 @@ empty_parms () ...@@ -256,7 +256,6 @@ empty_parms ()
%type <ttype> template_type_parm %type <ttype> template_type_parm
%type <code> template_close_bracket %type <code> template_close_bracket
%type <ttype> template_type template_arg_list template_arg %type <ttype> template_type template_arg_list template_arg
/* %type <itype> try_for_typename */
%type <ttype> condition xcond paren_cond_or_null %type <ttype> condition xcond paren_cond_or_null
%type <ttype> type_name nested_name_specifier nested_type ptr_to_mem %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
%type <ttype> complete_type_name notype_identifier %type <ttype> complete_type_name notype_identifier
...@@ -303,7 +302,8 @@ extern tree combine_strings PROTO((tree)); ...@@ -303,7 +302,8 @@ extern tree combine_strings PROTO((tree));
%} %}
%% %%
program: /* empty */ program:
/* empty */
| extdefs | extdefs
{ {
/* In case there were missing closebraces, /* In case there were missing closebraces,
...@@ -319,7 +319,8 @@ program: /* empty */ ...@@ -319,7 +319,8 @@ program: /* empty */
can find a valid list of type and sc specs in $0. */ can find a valid list of type and sc specs in $0. */
extdefs: extdefs:
{ $<ttype>$ = NULL_TREE; } lang_extdef { $<ttype>$ = NULL_TREE; }
lang_extdef
{ $<ttype>$ = NULL_TREE; } { $<ttype>$ = NULL_TREE; }
| extdefs lang_extdef | extdefs lang_extdef
{ $<ttype>$ = NULL_TREE; } { $<ttype>$ = NULL_TREE; }
...@@ -473,7 +474,8 @@ overloaddef: ...@@ -473,7 +474,8 @@ overloaddef:
{ warning ("use of `overload' is an anachronism"); } { warning ("use of `overload' is an anachronism"); }
; ;
ov_identifiers: IDENTIFIER ov_identifiers:
IDENTIFIER
{ declare_overloaded ($1); } { declare_overloaded ($1); }
| ov_identifiers ',' IDENTIFIER | ov_identifiers ',' IDENTIFIER
{ declare_overloaded ($3); } { declare_overloaded ($3); }
...@@ -493,27 +495,10 @@ datadef: ...@@ -493,27 +495,10 @@ datadef:
{} {}
| declmods notype_initdecls ';' | declmods notype_initdecls ';'
{} {}
/* Normal case to make fast: "const i;". */
| declmods notype_declarator ';'
{ tree d, specs, attrs;
split_specs_attrs ($1, &specs, &attrs);
d = start_decl ($<ttype>2, specs, 0, NULL_TREE);
cplus_decl_attributes (d, NULL_TREE, attrs);
cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0);
}
| typed_declspecs initdecls ';' | typed_declspecs initdecls ';'
{ {
note_list_got_semicolon ($1.t); note_list_got_semicolon ($1.t);
} }
/* Normal case: make this fast. */
| typed_declspecs declarator ';'
{ tree d, specs, attrs;
split_specs_attrs ($1.t, &specs, &attrs);
note_list_got_semicolon (specs);
d = start_decl ($2, specs, 0, NULL_TREE);
cplus_decl_attributes (d, NULL_TREE, attrs);
cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0);
}
| declmods ';' | declmods ';'
{ pedwarn ("empty declaration"); } { pedwarn ("empty declaration"); }
| explicit_instantiation ';' | explicit_instantiation ';'
...@@ -553,12 +538,6 @@ fndef: ...@@ -553,12 +538,6 @@ fndef:
| fn.def1 maybe_return_init function_try_block | fn.def1 maybe_return_init function_try_block
{ if ($<ttype>$) process_next_inline ($<ttype>$); } { if ($<ttype>$) process_next_inline ($<ttype>$); }
eat_saved_input eat_saved_input
| typed_declspecs declarator error
{}
| declmods notype_declarator error
{}
| notype_declarator error
{}
; ;
constructor_declarator: constructor_declarator:
...@@ -571,9 +550,9 @@ constructor_declarator: ...@@ -571,9 +550,9 @@ constructor_declarator:
TREE_COMPLEXITY ($$) = current_class_depth; TREE_COMPLEXITY ($$) = current_class_depth;
} }
} }
parmlist ')' type_quals parmlist ')' cv_qualifiers exception_specification_opt
{ $$ = build_parse_node (CALL_EXPR, $<ttype>4, $5, $7); } { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
| nested_name_specifier SELFNAME LEFT_RIGHT type_quals | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
{ {
$$ = build_parse_node (SCOPE_REF, $1, $2); $$ = build_parse_node (SCOPE_REF, $1, $2);
if ($1 != current_class_type) if ($1 != current_class_type)
...@@ -581,7 +560,7 @@ constructor_declarator: ...@@ -581,7 +560,7 @@ constructor_declarator:
push_nested_class ($1, 3); push_nested_class ($1, 3);
TREE_COMPLEXITY ($$) = current_class_depth; TREE_COMPLEXITY ($$) = current_class_depth;
} }
$$ = build_parse_node (CALL_EXPR, $$, empty_parms (), $4); $$ = make_call_declarator ($$, empty_parms (), $4, $5);
} }
| global_scope nested_name_specifier SELFNAME '(' | global_scope nested_name_specifier SELFNAME '('
{ {
...@@ -592,9 +571,9 @@ constructor_declarator: ...@@ -592,9 +571,9 @@ constructor_declarator:
TREE_COMPLEXITY ($$) = current_class_depth; TREE_COMPLEXITY ($$) = current_class_depth;
} }
} }
parmlist ')' type_quals parmlist ')' cv_qualifiers exception_specification_opt
{ $$ = build_parse_node (CALL_EXPR, $<ttype>5, $6, $8); } { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
| global_scope nested_name_specifier SELFNAME LEFT_RIGHT type_quals | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
{ {
$$ = build_parse_node (SCOPE_REF, $2, $3); $$ = build_parse_node (SCOPE_REF, $2, $3);
if ($2 != current_class_type) if ($2 != current_class_type)
...@@ -602,7 +581,7 @@ constructor_declarator: ...@@ -602,7 +581,7 @@ constructor_declarator:
push_nested_class ($2, 3); push_nested_class ($2, 3);
TREE_COMPLEXITY ($$) = current_class_depth; TREE_COMPLEXITY ($$) = current_class_depth;
} }
$$ = build_parse_node (CALL_EXPR, $$, empty_parms (), $5); $$ = make_call_declarator ($$, empty_parms (), $5, $6);
} }
| nested_name_specifier self_template_type '(' | nested_name_specifier self_template_type '('
{ {
...@@ -613,9 +592,9 @@ constructor_declarator: ...@@ -613,9 +592,9 @@ constructor_declarator:
TREE_COMPLEXITY ($$) = current_class_depth; TREE_COMPLEXITY ($$) = current_class_depth;
} }
} }
parmlist ')' type_quals parmlist ')' cv_qualifiers exception_specification_opt
{ $$ = build_parse_node (CALL_EXPR, $<ttype>4, $5, $7); } { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
| nested_name_specifier self_template_type LEFT_RIGHT type_quals | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
{ {
$$ = build_parse_node (SCOPE_REF, $1, $2); $$ = build_parse_node (SCOPE_REF, $1, $2);
if ($1 != current_class_type) if ($1 != current_class_type)
...@@ -623,7 +602,7 @@ constructor_declarator: ...@@ -623,7 +602,7 @@ constructor_declarator:
push_nested_class ($1, 3); push_nested_class ($1, 3);
TREE_COMPLEXITY ($$) = current_class_depth; TREE_COMPLEXITY ($$) = current_class_depth;
} }
$$ = build_parse_node (CALL_EXPR, $$, empty_parms (), $4); $$ = make_call_declarator ($$, empty_parms (), $4, $5);
} }
| global_scope nested_name_specifier self_template_type '(' | global_scope nested_name_specifier self_template_type '('
{ {
...@@ -634,9 +613,9 @@ constructor_declarator: ...@@ -634,9 +613,9 @@ constructor_declarator:
TREE_COMPLEXITY ($$) = current_class_depth; TREE_COMPLEXITY ($$) = current_class_depth;
} }
} }
parmlist ')' type_quals parmlist ')' cv_qualifiers exception_specification_opt
{ $$ = build_parse_node (CALL_EXPR, $<ttype>5, $6, $8); } { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
| global_scope nested_name_specifier self_template_type LEFT_RIGHT type_quals | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
{ {
$$ = build_parse_node (SCOPE_REF, $2, $3); $$ = build_parse_node (SCOPE_REF, $2, $3);
if ($2 != current_class_type) if ($2 != current_class_type)
...@@ -644,85 +623,86 @@ constructor_declarator: ...@@ -644,85 +623,86 @@ constructor_declarator:
push_nested_class ($2, 3); push_nested_class ($2, 3);
TREE_COMPLEXITY ($$) = current_class_depth; TREE_COMPLEXITY ($$) = current_class_depth;
} }
$$ = build_parse_node (CALL_EXPR, $$, empty_parms (), $5); $$ = make_call_declarator ($$, empty_parms (), $5, $6);
} }
; ;
fn.def1: fn.def1:
typed_declspecs declarator exception_specification_opt typed_declspecs declarator
{ tree specs, attrs; { tree specs, attrs;
split_specs_attrs ($1.t, &specs, &attrs); split_specs_attrs ($1.t, &specs, &attrs);
if (! start_function (specs, $2, $3, attrs, 0)) if (! start_function (specs, $2, attrs, 0))
YYERROR1; YYERROR1;
reinit_parse_for_function (); reinit_parse_for_function ();
$$ = NULL_TREE; } $$ = NULL_TREE; }
| declmods notype_declarator exception_specification_opt | declmods notype_declarator
{ tree specs, attrs; { tree specs, attrs;
split_specs_attrs ($1, &specs, &attrs); split_specs_attrs ($1, &specs, &attrs);
if (! start_function (specs, $2, $3, attrs, 0)) if (! start_function (specs, $2, attrs, 0))
YYERROR1; YYERROR1;
reinit_parse_for_function (); reinit_parse_for_function ();
$$ = NULL_TREE; } $$ = NULL_TREE; }
| notype_declarator exception_specification_opt | notype_declarator
{ if (! start_function (NULL_TREE, $$, $2, NULL_TREE, 0)) { if (! start_function (NULL_TREE, $$, NULL_TREE, 0))
YYERROR1; YYERROR1;
reinit_parse_for_function (); reinit_parse_for_function ();
$$ = NULL_TREE; } $$ = NULL_TREE; }
| declmods constructor_declarator exception_specification_opt | declmods constructor_declarator
{ tree specs, attrs; { tree specs, attrs;
split_specs_attrs ($1, &specs, &attrs); split_specs_attrs ($1, &specs, &attrs);
if (! start_function (specs, $2, $3, attrs, 0)) if (! start_function (specs, $2, attrs, 0))
YYERROR1; YYERROR1;
reinit_parse_for_function (); reinit_parse_for_function ();
$$ = NULL_TREE; } $$ = NULL_TREE; }
| constructor_declarator exception_specification_opt | constructor_declarator
{ if (! start_function (NULL_TREE, $$, $2, NULL_TREE, 0)) { if (! start_function (NULL_TREE, $$, NULL_TREE, 0))
YYERROR1; YYERROR1;
reinit_parse_for_function (); reinit_parse_for_function ();
$$ = NULL_TREE; } $$ = NULL_TREE; }
; ;
component_constructor_declarator: component_constructor_declarator:
SELFNAME '(' parmlist ')' type_quals SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
{ $$ = build_parse_node (CALL_EXPR, $1, $3, $5); } { $$ = make_call_declarator ($1, $3, $5, $6); }
| SELFNAME LEFT_RIGHT type_quals | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
{ $$ = build_parse_node (CALL_EXPR, $1, empty_parms (), $3); } { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
| self_template_type '(' parmlist ')' type_quals | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
{ $$ = build_parse_node (CALL_EXPR, $1, $3, $5); } { $$ = make_call_declarator ($1, $3, $5, $6); }
| self_template_type LEFT_RIGHT type_quals | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
{ $$ = build_parse_node (CALL_EXPR, $1, empty_parms (), $3); } { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
; ;
/* more C++ complexity. See component_decl for a comment on the /* more C++ complexity. See component_decl for a comment on the
reduce/reduce conflict introduced by these rules. */ reduce/reduce conflict introduced by these rules. */
fn.def2: fn.def2:
declmods component_constructor_declarator exception_specification_opt declmods component_constructor_declarator
{ tree specs = strip_attrs ($1); { tree specs = strip_attrs ($1);
$$ = start_method (specs, $2, $3); $$ = start_method (specs, $2);
rest_of_mdef: rest_of_mdef:
if (! $$) if (! $$)
YYERROR1; YYERROR1;
if (yychar == YYEMPTY) if (yychar == YYEMPTY)
yychar = YYLEX; yychar = YYLEX;
reinit_parse_for_method (yychar, $$); } reinit_parse_for_method (yychar, $$); }
| component_constructor_declarator exception_specification_opt | component_constructor_declarator
{ $$ = start_method (NULL_TREE, $1, $2); goto rest_of_mdef; } { $$ = start_method (NULL_TREE, $1); goto rest_of_mdef; }
| typed_declspecs declarator exception_specification_opt | typed_declspecs declarator
{ tree specs = strip_attrs ($1.t); { tree specs = strip_attrs ($1.t);
$$ = start_method (specs, $2, $3); goto rest_of_mdef; } $$ = start_method (specs, $2); goto rest_of_mdef; }
| declmods notype_declarator exception_specification_opt | declmods notype_declarator
{ tree specs = strip_attrs ($1); { tree specs = strip_attrs ($1);
$$ = start_method (specs, $2, $3); goto rest_of_mdef; } $$ = start_method (specs, $2); goto rest_of_mdef; }
| notype_declarator exception_specification_opt | notype_declarator
{ $$ = start_method (NULL_TREE, $$, $2); goto rest_of_mdef; } { $$ = start_method (NULL_TREE, $$); goto rest_of_mdef; }
| declmods constructor_declarator exception_specification_opt | declmods constructor_declarator
{ tree specs = strip_attrs ($1); { tree specs = strip_attrs ($1);
$$ = start_method (specs, $2, $3); goto rest_of_mdef; } $$ = start_method (specs, $2); goto rest_of_mdef; }
| constructor_declarator exception_specification_opt | constructor_declarator
{ $$ = start_method (NULL_TREE, $$, $2); goto rest_of_mdef; } { $$ = start_method (NULL_TREE, $$); goto rest_of_mdef; }
; ;
return_id: RETURN IDENTIFIER return_id:
RETURN IDENTIFIER
{ {
if (! current_function_parms_stored) if (! current_function_parms_stored)
store_parm_decls (); store_parm_decls ();
...@@ -730,7 +710,8 @@ return_id: RETURN IDENTIFIER ...@@ -730,7 +710,8 @@ return_id: RETURN IDENTIFIER
} }
; ;
return_init: return_id maybe_init return_init:
return_id maybe_init
{ store_return_init ($<ttype>$, $2); } { store_return_init ($<ttype>$, $2); }
| return_id '(' nonnull_exprlist ')' | return_id '(' nonnull_exprlist ')'
{ store_return_init ($<ttype>$, $3); } { store_return_init ($<ttype>$, $3); }
...@@ -780,7 +761,8 @@ member_init_list: ...@@ -780,7 +761,8 @@ member_init_list:
| member_init_list error | member_init_list error
; ;
member_init: '(' nonnull_exprlist ')' member_init:
'(' nonnull_exprlist ')'
{ {
if (current_class_name && !flag_traditional) if (current_class_name && !flag_traditional)
pedwarn ("anachronistic old style base class initializer"); pedwarn ("anachronistic old style base class initializer");
...@@ -922,7 +904,8 @@ template_arg: ...@@ -922,7 +904,8 @@ template_arg:
| expr_no_commas %prec ARITHCOMPARE | expr_no_commas %prec ARITHCOMPARE
; ;
unop: '-' unop:
'-'
{ $$ = NEGATE_EXPR; } { $$ = NEGATE_EXPR; }
| '+' | '+'
{ $$ = CONVERT_EXPR; } { $$ = CONVERT_EXPR; }
...@@ -934,7 +917,8 @@ unop: '-' ...@@ -934,7 +917,8 @@ unop: '-'
{ $$ = TRUTH_NOT_EXPR; } { $$ = TRUTH_NOT_EXPR; }
; ;
expr: nontrivial_exprlist expr:
nontrivial_exprlist
{ $$ = build_x_compound_expr ($$); } { $$ = build_x_compound_expr ($$); }
| expr_no_commas | expr_no_commas
; ;
...@@ -967,7 +951,7 @@ xcond: ...@@ -967,7 +951,7 @@ xcond:
; ;
condition: condition:
type_specifier_seq declarator exception_specification_opt maybeasm maybe_attribute '=' type_specifier_seq declarator maybeasm maybe_attribute '='
{ { { {
tree d; tree d;
for (d = getdecls (); d; d = TREE_CHAIN (d)) for (d = getdecls (); d; d = TREE_CHAIN (d))
...@@ -980,16 +964,16 @@ condition: ...@@ -980,16 +964,16 @@ condition:
} }
} }
current_declspecs = $1.t; current_declspecs = $1.t;
$<itype>6 = suspend_momentary (); $<itype>5 = suspend_momentary ();
$<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1, $3); $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1);
cplus_decl_attributes ($<ttype>$, $5, cplus_decl_attributes ($<ttype>$, $4,
/*prefix_attributes*/ NULL_TREE); /*prefix_attributes*/ NULL_TREE);
} }
init init
{ {
cp_finish_decl ($<ttype>7, $8, $5, 1, LOOKUP_ONLYCONVERTING); cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
resume_momentary ($<itype>6); resume_momentary ($<itype>5);
$$ = $<ttype>7; $$ = $<ttype>6;
if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE) if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
cp_error ("definition of array `%#D' in condition", $$); cp_error ("definition of array `%#D' in condition", $$);
} }
...@@ -1166,13 +1150,12 @@ regcast_or_absdcl: ...@@ -1166,13 +1150,12 @@ regcast_or_absdcl:
'(' type_id ')' %prec EMPTY '(' type_id ')' %prec EMPTY
{ $2.t = tree_cons (NULL_TREE, $2.t, void_list_node); { $2.t = tree_cons (NULL_TREE, $2.t, void_list_node);
TREE_PARMLIST ($2.t) = 1; TREE_PARMLIST ($2.t) = 1;
$$ = build_parse_node (CALL_EXPR, NULL_TREE, $2.t, $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
NULL_TREE);
check_for_new_type ("cast", $2); } check_for_new_type ("cast", $2); }
| regcast_or_absdcl '(' type_id ')' %prec EMPTY | regcast_or_absdcl '(' type_id ')' %prec EMPTY
{ $3.t = tree_cons (NULL_TREE, $3.t, void_list_node); { $3.t = tree_cons (NULL_TREE, $3.t, void_list_node);
TREE_PARMLIST ($3.t) = 1; TREE_PARMLIST ($3.t) = 1;
$$ = build_parse_node (CALL_EXPR, $$, $3.t, NULL_TREE); $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
check_for_new_type ("cast", $3); } check_for_new_type ("cast", $3); }
; ;
...@@ -1410,7 +1393,7 @@ primary: ...@@ -1410,7 +1393,7 @@ primary:
$$ = error_mark_node; $$ = error_mark_node;
} }
} }
| TYPE_QUAL '(' nonnull_exprlist ')' | CV_QUALIFIER '(' nonnull_exprlist ')'
{ {
tree type; tree type;
tree id = $$; tree id = $$;
...@@ -1621,13 +1604,15 @@ primary_no_id: ...@@ -1621,13 +1604,15 @@ primary_no_id:
; ;
*/ */
new: NEW new:
NEW
{ $$ = 0; } { $$ = 0; }
| global_scope NEW | global_scope NEW
{ got_scope = NULL_TREE; $$ = 1; } { got_scope = NULL_TREE; $$ = 1; }
; ;
delete: DELETE delete:
DELETE
{ $$ = 0; } { $$ = 0; }
| global_scope delete | global_scope delete
{ got_scope = NULL_TREE; $$ = 1; } { got_scope = NULL_TREE; $$ = 1; }
...@@ -1660,7 +1645,8 @@ nodecls: ...@@ -1660,7 +1645,8 @@ nodecls:
} }
; ;
object: primary '.' object:
primary '.'
{ got_object = TREE_TYPE ($$); } { got_object = TREE_TYPE ($$); }
| primary POINTSAT | primary POINTSAT
{ {
...@@ -1670,28 +1656,7 @@ object: primary '.' ...@@ -1670,28 +1656,7 @@ object: primary '.'
; ;
decl: decl:
/* Normal case: make this fast. */ typespec initdecls ';'
typespec declarator ';'
{ tree d = get_decl_list ($1.t);
int yes = suspend_momentary ();
d = start_decl ($2, d, 0, NULL_TREE);
cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0);
resume_momentary (yes);
if (IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
note_got_semicolon ($1.t);
}
| typed_declspecs declarator ';'
{ tree d, specs, attrs;
int yes;
split_specs_attrs ($1.t, &specs, &attrs);
yes = suspend_momentary ();
d = start_decl ($2, specs, 0, NULL_TREE);
cplus_decl_attributes (d, NULL_TREE, attrs);
cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0);
resume_momentary (yes);
note_list_got_semicolon ($1.t);
}
| typespec initdecls ';'
{ {
resume_momentary ($2); resume_momentary ($2);
if (IS_AGGR_TYPE_CODE (TREE_CODE ($1.t))) if (IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
...@@ -1724,10 +1689,10 @@ declarator: ...@@ -1724,10 +1689,10 @@ declarator:
/* This is necessary to postpone reduction of `int()()()()'. */ /* This is necessary to postpone reduction of `int()()()()'. */
fcast_or_absdcl: fcast_or_absdcl:
LEFT_RIGHT %prec EMPTY LEFT_RIGHT %prec EMPTY
{ $$ = build_parse_node (CALL_EXPR, NULL_TREE, empty_parms (), { $$ = make_call_declarator (NULL_TREE, empty_parms (),
NULL_TREE); } NULL_TREE, NULL_TREE); }
| fcast_or_absdcl LEFT_RIGHT %prec EMPTY | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
{ $$ = build_parse_node (CALL_EXPR, $$, empty_parms (), { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
NULL_TREE); } NULL_TREE); }
; ;
...@@ -1736,7 +1701,7 @@ type_id: ...@@ -1736,7 +1701,7 @@ type_id:
typed_typespecs absdcl typed_typespecs absdcl
{ $$.t = build_decl_list ($1.t, $2); { $$.t = build_decl_list ($1.t, $2);
$$.new_type_flag = $1.new_type_flag; } $$.new_type_flag = $1.new_type_flag; }
| nonempty_type_quals absdcl | nonempty_cv_qualifiers absdcl
{ $$.t = build_decl_list ($1.t, $2); { $$.t = build_decl_list ($1.t, $2);
$$.new_type_flag = $1.new_type_flag; } $$.new_type_flag = $1.new_type_flag; }
| typespec absdcl | typespec absdcl
...@@ -1745,7 +1710,7 @@ type_id: ...@@ -1745,7 +1710,7 @@ type_id:
| typed_typespecs %prec EMPTY | typed_typespecs %prec EMPTY
{ $$.t = build_decl_list ($1.t, NULL_TREE); { $$.t = build_decl_list ($1.t, NULL_TREE);
$$.new_type_flag = $1.new_type_flag; } $$.new_type_flag = $1.new_type_flag; }
| nonempty_type_quals %prec EMPTY | nonempty_cv_qualifiers %prec EMPTY
{ $$.t = build_decl_list ($1.t, NULL_TREE); { $$.t = build_decl_list ($1.t, NULL_TREE);
$$.new_type_flag = $1.new_type_flag; } $$.new_type_flag = $1.new_type_flag; }
; ;
...@@ -1807,11 +1772,11 @@ reserved_declspecs: ...@@ -1807,11 +1772,11 @@ reserved_declspecs:
In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */ In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
declmods: declmods:
nonempty_type_quals %prec EMPTY nonempty_cv_qualifiers %prec EMPTY
{ $$ = $1.t; TREE_STATIC ($$) = 1; } { $$ = $1.t; TREE_STATIC ($$) = 1; }
| SCSPEC | SCSPEC
{ $$ = IDENTIFIER_AS_LIST ($$); } { $$ = IDENTIFIER_AS_LIST ($$); }
| declmods TYPE_QUAL | declmods CV_QUALIFIER
{ $$ = decl_tree_cons (NULL_TREE, $2, $$); { $$ = decl_tree_cons (NULL_TREE, $2, $$);
TREE_STATIC ($$) = 1; } TREE_STATIC ($$) = 1; }
| declmods SCSPEC | declmods SCSPEC
...@@ -1836,13 +1801,13 @@ typed_typespecs: ...@@ -1836,13 +1801,13 @@ typed_typespecs:
typespec %prec EMPTY typespec %prec EMPTY
{ $$.t = get_decl_list ($1.t); { $$.t = get_decl_list ($1.t);
$$.new_type_flag = $1.new_type_flag; } $$.new_type_flag = $1.new_type_flag; }
| nonempty_type_quals typespec | nonempty_cv_qualifiers typespec
{ $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t); { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
$$.new_type_flag = $2.new_type_flag; } $$.new_type_flag = $2.new_type_flag; }
| typespec reserved_typespecquals | typespec reserved_typespecquals
{ $$.t = decl_tree_cons (NULL_TREE, $1.t, $2); { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
$$.new_type_flag = $1.new_type_flag; } $$.new_type_flag = $1.new_type_flag; }
| nonempty_type_quals typespec reserved_typespecquals | nonempty_cv_qualifiers typespec reserved_typespecquals
{ $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t)); { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
$$.new_type_flag = $1.new_type_flag; } $$.new_type_flag = $1.new_type_flag; }
; ;
...@@ -1858,7 +1823,8 @@ reserved_typespecquals: ...@@ -1858,7 +1823,8 @@ reserved_typespecquals:
Once we have seen one of these in a declaration, Once we have seen one of these in a declaration,
if a typedef name appears then it is being redeclared. */ if a typedef name appears then it is being redeclared. */
typespec: structsp typespec:
structsp
| TYPESPEC %prec EMPTY | TYPESPEC %prec EMPTY
{ $$.t = $1; $$.new_type_flag = 0; } { $$.t = $1; $$.new_type_flag = 0; }
| complete_type_name | complete_type_name
...@@ -1907,9 +1873,10 @@ typespec: structsp ...@@ -1907,9 +1873,10 @@ typespec: structsp
/* A typespec that is a reserved word, or a type qualifier. */ /* A typespec that is a reserved word, or a type qualifier. */
typespecqual_reserved: TYPESPEC typespecqual_reserved:
TYPESPEC
{ $$.t = $1; $$.new_type_flag = 0; } { $$.t = $1; $$.new_type_flag = 0; }
| TYPE_QUAL | CV_QUALIFIER
{ $$.t = $1; $$.new_type_flag = 0; } { $$.t = $1; $$.new_type_flag = 0; }
| structsp | structsp
; ;
...@@ -1937,7 +1904,7 @@ maybeasm: ...@@ -1937,7 +1904,7 @@ maybeasm:
; ;
initdcl0: initdcl0:
declarator exception_specification_opt maybeasm maybe_attribute '=' declarator maybeasm maybe_attribute '='
{ split_specs_attrs ($<ttype>0, &current_declspecs, { split_specs_attrs ($<ttype>0, &current_declspecs,
&prefix_attributes); &prefix_attributes);
if (TREE_CODE (current_declspecs) != TREE_LIST) if (TREE_CODE (current_declspecs) != TREE_LIST)
...@@ -1949,14 +1916,14 @@ initdcl0: ...@@ -1949,14 +1916,14 @@ initdcl0:
current_declspecs); current_declspecs);
used_extern_spec = 1; used_extern_spec = 1;
} }
$<itype>5 = suspend_momentary (); $<itype>4 = suspend_momentary ();
$<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2); $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1);
cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); } cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
init init
/* Note how the declaration of the variable is in effect while its init is parsed! */ /* Note how the declaration of the variable is in effect while its init is parsed! */
{ cp_finish_decl ($<ttype>6, $7, $3, 1, LOOKUP_ONLYCONVERTING); { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING);
$$ = $<itype>5; } $$ = $<itype>4; }
| declarator exception_specification_opt maybeasm maybe_attribute | declarator maybeasm maybe_attribute
{ tree d; { tree d;
split_specs_attrs ($<ttype>0, &current_declspecs, split_specs_attrs ($<ttype>0, &current_declspecs,
&prefix_attributes); &prefix_attributes);
...@@ -1970,64 +1937,64 @@ initdcl0: ...@@ -1970,64 +1937,64 @@ initdcl0:
used_extern_spec = 1; used_extern_spec = 1;
} }
$$ = suspend_momentary (); $$ = suspend_momentary ();
d = start_decl ($<ttype>1, current_declspecs, 0, $2); d = start_decl ($<ttype>1, current_declspecs, 0);
cplus_decl_attributes (d, $4, prefix_attributes); cplus_decl_attributes (d, $3, prefix_attributes);
cp_finish_decl (d, NULL_TREE, $3, 1, 0); } cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
; ;
initdcl: initdcl:
declarator exception_specification_opt maybeasm maybe_attribute '=' declarator maybeasm maybe_attribute '='
{ $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2); { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1);
cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); } cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
init init
/* Note how the declaration of the variable is in effect while its init is parsed! */ /* Note how the declaration of the variable is in effect while its init is parsed! */
{ cp_finish_decl ($<ttype>6, $7, $3, 1, LOOKUP_ONLYCONVERTING); } { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
| declarator exception_specification_opt maybeasm maybe_attribute | declarator maybeasm maybe_attribute
{ $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0, $2); { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0);
cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); cplus_decl_attributes ($<ttype>$, $3, prefix_attributes);
cp_finish_decl ($<ttype>$, NULL_TREE, $3, 1, 0); } cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
; ;
notype_initdcl0: notype_initdcl0:
notype_declarator exception_specification_opt maybeasm maybe_attribute '=' notype_declarator maybeasm maybe_attribute '='
{ split_specs_attrs ($<ttype>0, &current_declspecs, { split_specs_attrs ($<ttype>0, &current_declspecs,
&prefix_attributes); &prefix_attributes);
$<itype>5 = suspend_momentary (); $<itype>4 = suspend_momentary ();
$<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2); $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1);
cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); } cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
init init
/* Note how the declaration of the variable is in effect while its init is parsed! */ /* Note how the declaration of the variable is in effect while its init is parsed! */
{ cp_finish_decl ($<ttype>6, $7, $3, 1, LOOKUP_ONLYCONVERTING); { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING);
$$ = $<itype>5; } $$ = $<itype>4; }
| notype_declarator exception_specification_opt maybeasm maybe_attribute | notype_declarator maybeasm maybe_attribute
{ tree d; { tree d;
split_specs_attrs ($<ttype>0, &current_declspecs, split_specs_attrs ($<ttype>0, &current_declspecs,
&prefix_attributes); &prefix_attributes);
$$ = suspend_momentary (); $$ = suspend_momentary ();
d = start_decl ($<ttype>1, current_declspecs, 0, $2); d = start_decl ($<ttype>1, current_declspecs, 0);
cplus_decl_attributes (d, $4, prefix_attributes); cplus_decl_attributes (d, $3, prefix_attributes);
cp_finish_decl (d, NULL_TREE, $3, 1, 0); } cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
; ;
nomods_initdcl0: nomods_initdcl0:
notype_declarator exception_specification_opt maybeasm maybe_attribute '=' notype_declarator maybeasm maybe_attribute '='
{ current_declspecs = NULL_TREE; { current_declspecs = NULL_TREE;
prefix_attributes = NULL_TREE; prefix_attributes = NULL_TREE;
$<itype>5 = suspend_momentary (); $<itype>4 = suspend_momentary ();
$<ttype>$ = start_decl ($1, current_declspecs, 1, $2); $<ttype>$ = start_decl ($1, current_declspecs, 1);
cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); } cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
init init
/* Note how the declaration of the variable is in effect while its init is parsed! */ /* Note how the declaration of the variable is in effect while its init is parsed! */
{ cp_finish_decl ($<ttype>6, $7, $3, 1, LOOKUP_ONLYCONVERTING); { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING);
$$ = $<itype>5; } $$ = $<itype>4; }
| notype_declarator exception_specification_opt maybeasm maybe_attribute | notype_declarator maybeasm maybe_attribute
{ tree d; { tree d;
current_declspecs = NULL_TREE; current_declspecs = NULL_TREE;
prefix_attributes = NULL_TREE; prefix_attributes = NULL_TREE;
$$ = suspend_momentary (); $$ = suspend_momentary ();
d = start_decl ($1, current_declspecs, 0, $2); d = start_decl ($1, current_declspecs, 0);
cplus_decl_attributes (d, $4, prefix_attributes); cplus_decl_attributes (d, $3, prefix_attributes);
cp_finish_decl (d, NULL_TREE, $3, 1, 0); } cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
; ;
/* the * rules are dummies to accept the Apollo extended syntax /* the * rules are dummies to accept the Apollo extended syntax
...@@ -2078,7 +2045,7 @@ any_word: ...@@ -2078,7 +2045,7 @@ any_word:
identifier identifier
| SCSPEC | SCSPEC
| TYPESPEC | TYPESPEC
| TYPE_QUAL | CV_QUALIFIER
; ;
/* A nonempty list of identifiers, including typenames. */ /* A nonempty list of identifiers, including typenames. */
...@@ -2090,7 +2057,7 @@ identifiers_or_typenames: ...@@ -2090,7 +2057,7 @@ identifiers_or_typenames:
; ;
maybe_init: maybe_init:
%prec EMPTY /* empty */ /* empty */ %prec EMPTY
{ $$ = NULL_TREE; } { $$ = NULL_TREE; }
| '=' init | '=' init
{ $$ = $2; } { $$ = $2; }
...@@ -2134,7 +2101,7 @@ initlist: ...@@ -2134,7 +2101,7 @@ initlist:
fn.defpen: fn.defpen:
PRE_PARSED_FUNCTION_DECL PRE_PARSED_FUNCTION_DECL
{ start_function (NULL_TREE, TREE_VALUE ($1), { start_function (NULL_TREE, TREE_VALUE ($1),
NULL_TREE, NULL_TREE, 1); NULL_TREE, 1);
reinit_parse_for_function (); } reinit_parse_for_function (); }
pending_inlines: pending_inlines:
...@@ -2252,12 +2219,13 @@ maybecomma_warn: ...@@ -2252,12 +2219,13 @@ maybecomma_warn:
pedwarn ("comma at end of enumerator list"); } pedwarn ("comma at end of enumerator list"); }
; ;
aggr: AGGR aggr:
AGGR
| aggr SCSPEC | aggr SCSPEC
{ error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); } { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
| aggr TYPESPEC | aggr TYPESPEC
{ error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); } { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
| aggr TYPE_QUAL | aggr CV_QUALIFIER
{ error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); } { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
| aggr AGGR | aggr AGGR
{ error ("no body nor ';' separates two class, struct or union declarations"); } { error ("no body nor ';' separates two class, struct or union declarations"); }
...@@ -2294,7 +2262,8 @@ named_complex_class_head_sans_basetype: ...@@ -2294,7 +2262,8 @@ named_complex_class_head_sans_basetype:
{ current_aggr = $$; $$ = $3; } { current_aggr = $$; $$ = $3; }
; ;
do_xref_defn: /* empty */ %prec EMPTY do_xref_defn:
/* empty */ %prec EMPTY
{ $<ttype>$ = xref_tag (current_aggr, $<ttype>0, NULL_TREE, 0); } { $<ttype>$ = xref_tag (current_aggr, $<ttype>0, NULL_TREE, 0); }
; ;
...@@ -2336,15 +2305,19 @@ named_class_head: ...@@ -2336,15 +2305,19 @@ named_class_head:
} }
; ;
unnamed_class_head: aggr '{' unnamed_class_head:
aggr '{'
{ $$ = xref_tag ($$, make_anon_name (), NULL_TREE, 0); { $$ = xref_tag ($$, make_anon_name (), NULL_TREE, 0);
yyungetc ('{', 1); } yyungetc ('{', 1); }
; ;
class_head: unnamed_class_head | named_class_head ; class_head:
unnamed_class_head
| named_class_head
;
maybe_base_class_list: maybe_base_class_list:
%prec EMPTY /* empty */ /* empty */ %prec EMPTY
{ $$ = NULL_TREE; } { $$ = NULL_TREE; }
| ':' see_typename %prec EMPTY | ':' see_typename %prec EMPTY
{ yyungetc(':', 1); $$ = NULL_TREE; } { yyungetc(':', 1); $$ = NULL_TREE; }
...@@ -2504,7 +2477,8 @@ base_class_access_list: ...@@ -2504,7 +2477,8 @@ base_class_access_list:
$$ = access_private_virtual_node; } $$ = access_private_virtual_node; }
; ;
left_curly: '{' left_curly:
'{'
{ tree t = $<ttype>0; { tree t = $<ttype>0;
push_obstacks_nochange (); push_obstacks_nochange ();
end_temporary_allocation (); end_temporary_allocation ();
...@@ -2673,12 +2647,12 @@ component_decl_1: ...@@ -2673,12 +2647,12 @@ component_decl_1:
{ $$ = grok_x_components ($1.t, $2); } { $$ = grok_x_components ($1.t, $2); }
| declmods notype_components | declmods notype_components
{ $$ = grok_x_components ($1, $2); } { $$ = grok_x_components ($1, $2); }
| notype_declarator exception_specification_opt maybeasm maybe_attribute maybe_init | notype_declarator maybeasm maybe_attribute maybe_init
{ $$ = grokfield ($$, NULL_TREE, $2, $5, $3, { $$ = grokfield ($$, NULL_TREE, $4, $2,
build_tree_list ($4, NULL_TREE)); } build_tree_list ($3, NULL_TREE)); }
| constructor_declarator exception_specification_opt maybeasm maybe_attribute maybe_init | constructor_declarator maybeasm maybe_attribute maybe_init
{ $$ = grokfield ($$, NULL_TREE, $2, $5, $3, { $$ = grokfield ($$, NULL_TREE, $4, $2,
build_tree_list ($4, NULL_TREE)); } build_tree_list ($3, NULL_TREE)); }
| ':' expr_no_commas | ':' expr_no_commas
{ $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); } { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
| error | error
...@@ -2692,13 +2666,13 @@ component_decl_1: ...@@ -2692,13 +2666,13 @@ component_decl_1:
should "A::foo" be declared as a function or "A::bar" as a data should "A::foo" be declared as a function or "A::bar" as a data
member? In other words, is "bar" an after_type_declarator or a member? In other words, is "bar" an after_type_declarator or a
parmlist? */ parmlist? */
| declmods component_constructor_declarator exception_specification_opt maybeasm maybe_attribute maybe_init | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
{ tree specs, attrs; { tree specs, attrs;
split_specs_attrs ($1, &specs, &attrs); split_specs_attrs ($1, &specs, &attrs);
$$ = grokfield ($2, specs, $3, $6, $4, $$ = grokfield ($2, specs, $5, $3,
build_tree_list ($5, attrs)); } build_tree_list ($4, attrs)); }
| component_constructor_declarator exception_specification_opt maybeasm maybe_attribute maybe_init | component_constructor_declarator maybeasm maybe_attribute maybe_init
{ $$ = grokfield ($$, NULL_TREE, $2, $5, $3, $4); } { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
| using_decl | using_decl
{ $$ = do_class_using_decl ($1); } { $$ = do_class_using_decl ($1); }
; ;
...@@ -2746,12 +2720,12 @@ component_declarator: ...@@ -2746,12 +2720,12 @@ component_declarator:
; ;
after_type_component_declarator0: after_type_component_declarator0:
after_type_declarator exception_specification_opt maybeasm maybe_attribute maybe_init after_type_declarator maybeasm maybe_attribute maybe_init
{ split_specs_attrs ($<ttype>0, &current_declspecs, { split_specs_attrs ($<ttype>0, &current_declspecs,
&prefix_attributes); &prefix_attributes);
$<ttype>0 = current_declspecs; $<ttype>0 = current_declspecs;
$$ = grokfield ($$, current_declspecs, $2, $5, $3, $$ = grokfield ($$, current_declspecs, $4, $2,
build_tree_list ($4, prefix_attributes)); } build_tree_list ($3, prefix_attributes)); }
| TYPENAME ':' expr_no_commas maybe_attribute | TYPENAME ':' expr_no_commas maybe_attribute
{ split_specs_attrs ($<ttype>0, &current_declspecs, { split_specs_attrs ($<ttype>0, &current_declspecs,
&prefix_attributes); &prefix_attributes);
...@@ -2761,18 +2735,18 @@ after_type_component_declarator0: ...@@ -2761,18 +2735,18 @@ after_type_component_declarator0:
; ;
notype_component_declarator0: notype_component_declarator0:
notype_declarator exception_specification_opt maybeasm maybe_attribute maybe_init notype_declarator maybeasm maybe_attribute maybe_init
{ split_specs_attrs ($<ttype>0, &current_declspecs, { split_specs_attrs ($<ttype>0, &current_declspecs,
&prefix_attributes); &prefix_attributes);
$<ttype>0 = current_declspecs; $<ttype>0 = current_declspecs;
$$ = grokfield ($$, current_declspecs, $2, $5, $3, $$ = grokfield ($$, current_declspecs, $4, $2,
build_tree_list ($4, prefix_attributes)); } build_tree_list ($3, prefix_attributes)); }
| constructor_declarator exception_specification_opt maybeasm maybe_attribute maybe_init | constructor_declarator maybeasm maybe_attribute maybe_init
{ split_specs_attrs ($<ttype>0, &current_declspecs, { split_specs_attrs ($<ttype>0, &current_declspecs,
&prefix_attributes); &prefix_attributes);
$<ttype>0 = current_declspecs; $<ttype>0 = current_declspecs;
$$ = grokfield ($$, current_declspecs, $2, $5, $3, $$ = grokfield ($$, current_declspecs, $4, $2,
build_tree_list ($4, prefix_attributes)); } build_tree_list ($3, prefix_attributes)); }
| IDENTIFIER ':' expr_no_commas maybe_attribute | IDENTIFIER ':' expr_no_commas maybe_attribute
{ split_specs_attrs ($<ttype>0, &current_declspecs, { split_specs_attrs ($<ttype>0, &current_declspecs,
&prefix_attributes); &prefix_attributes);
...@@ -2788,18 +2762,18 @@ notype_component_declarator0: ...@@ -2788,18 +2762,18 @@ notype_component_declarator0:
; ;
after_type_component_declarator: after_type_component_declarator:
after_type_declarator exception_specification_opt maybeasm maybe_attribute maybe_init after_type_declarator maybeasm maybe_attribute maybe_init
{ $$ = grokfield ($$, current_declspecs, $2, $5, $3, { $$ = grokfield ($$, current_declspecs, $4, $2,
build_tree_list ($4, prefix_attributes)); } build_tree_list ($3, prefix_attributes)); }
| TYPENAME ':' expr_no_commas maybe_attribute | TYPENAME ':' expr_no_commas maybe_attribute
{ $$ = grokbitfield ($$, current_declspecs, $3); { $$ = grokbitfield ($$, current_declspecs, $3);
cplus_decl_attributes ($$, $4, prefix_attributes); } cplus_decl_attributes ($$, $4, prefix_attributes); }
; ;
notype_component_declarator: notype_component_declarator:
notype_declarator exception_specification_opt maybeasm maybe_attribute maybe_init notype_declarator maybeasm maybe_attribute maybe_init
{ $$ = grokfield ($$, current_declspecs, $2, $5, $3, { $$ = grokfield ($$, current_declspecs, $4, $2,
build_tree_list ($4, prefix_attributes)); } build_tree_list ($3, prefix_attributes)); }
| IDENTIFIER ':' expr_no_commas maybe_attribute | IDENTIFIER ':' expr_no_commas maybe_attribute
{ $$ = grokbitfield ($$, current_declspecs, $3); { $$ = grokbitfield ($$, current_declspecs, $3);
cplus_decl_attributes ($$, $4, prefix_attributes); } cplus_decl_attributes ($$, $4, prefix_attributes); }
...@@ -2845,18 +2819,18 @@ new_type_id: ...@@ -2845,18 +2819,18 @@ new_type_id:
} }
; ;
type_quals: cv_qualifiers:
/* empty */ %prec EMPTY /* empty */ %prec EMPTY
{ $$ = NULL_TREE; } { $$ = NULL_TREE; }
| type_quals TYPE_QUAL | cv_qualifiers CV_QUALIFIER
{ $$ = decl_tree_cons (NULL_TREE, $2, $$); } { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
; ;
nonempty_type_quals: nonempty_cv_qualifiers:
TYPE_QUAL CV_QUALIFIER
{ $$.t = IDENTIFIER_AS_LIST ($1); { $$.t = IDENTIFIER_AS_LIST ($1);
$$.new_type_flag = 0; } $$.new_type_flag = 0; }
| nonempty_type_quals TYPE_QUAL | nonempty_cv_qualifiers CV_QUALIFIER
{ $$.t = decl_tree_cons (NULL_TREE, $2, $1.t); { $$.t = decl_tree_cons (NULL_TREE, $2, $1.t);
$$.new_type_flag = $1.new_type_flag; } $$.new_type_flag = $1.new_type_flag; }
; ;
...@@ -2865,6 +2839,7 @@ nonempty_type_quals: ...@@ -2865,6 +2839,7 @@ nonempty_type_quals:
and component declarations. That way, longer rules are preferred. */ and component declarations. That way, longer rules are preferred. */
suspend_mom: suspend_mom:
/* empty */
{ $<itype>$ = suspend_momentary (); } { $<itype>$ = suspend_momentary (); }
/* An expression which will not live on the momentary obstack. */ /* An expression which will not live on the momentary obstack. */
...@@ -2888,15 +2863,15 @@ maybe_parmlist: ...@@ -2888,15 +2863,15 @@ maybe_parmlist:
/* A declarator that is allowed only after an explicit typespec. */ /* A declarator that is allowed only after an explicit typespec. */
/* may all be followed by prec '.' */ /* may all be followed by prec '.' */
after_type_declarator: after_type_declarator:
'*' nonempty_type_quals after_type_declarator %prec UNARY '*' nonempty_cv_qualifiers after_type_declarator %prec UNARY
{ $$ = make_pointer_declarator ($2.t, $3); } { $$ = make_pointer_declarator ($2.t, $3); }
| '&' nonempty_type_quals after_type_declarator %prec UNARY | '&' nonempty_cv_qualifiers after_type_declarator %prec UNARY
{ $$ = make_reference_declarator ($2.t, $3); } { $$ = make_reference_declarator ($2.t, $3); }
| '*' after_type_declarator %prec UNARY | '*' after_type_declarator %prec UNARY
{ $$ = make_pointer_declarator (NULL_TREE, $2); } { $$ = make_pointer_declarator (NULL_TREE, $2); }
| '&' after_type_declarator %prec UNARY | '&' after_type_declarator %prec UNARY
{ $$ = make_reference_declarator (NULL_TREE, $2); } { $$ = make_reference_declarator (NULL_TREE, $2); }
| ptr_to_mem type_quals after_type_declarator | ptr_to_mem cv_qualifiers after_type_declarator
{ tree arg = make_pointer_declarator ($2, $3); { tree arg = make_pointer_declarator ($2, $3);
$$ = build_parse_node (SCOPE_REF, $1, arg); $$ = build_parse_node (SCOPE_REF, $1, arg);
} }
...@@ -2943,8 +2918,8 @@ nested_type: ...@@ -2943,8 +2918,8 @@ nested_type:
; ;
direct_after_type_declarator: direct_after_type_declarator:
direct_after_type_declarator maybe_parmlist type_quals %prec '.' direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
{ $$ = build_parse_node (CALL_EXPR, $$, $2, $3); } { $$ = make_call_declarator ($$, $2, $3, $4); }
| direct_after_type_declarator '[' nonmomentary_expr ']' | direct_after_type_declarator '[' nonmomentary_expr ']'
{ $$ = build_parse_node (ARRAY_REF, $$, $3); } { $$ = build_parse_node (ARRAY_REF, $$, $3); }
| direct_after_type_declarator '[' ']' | direct_after_type_declarator '[' ']'
...@@ -2962,15 +2937,15 @@ direct_after_type_declarator: ...@@ -2962,15 +2937,15 @@ direct_after_type_declarator:
an explicit typespec. These cannot redeclare a typedef-name. */ an explicit typespec. These cannot redeclare a typedef-name. */
notype_declarator: notype_declarator:
'*' nonempty_type_quals notype_declarator %prec UNARY '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
{ $$ = make_pointer_declarator ($2.t, $3); } { $$ = make_pointer_declarator ($2.t, $3); }
| '&' nonempty_type_quals notype_declarator %prec UNARY | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
{ $$ = make_reference_declarator ($2.t, $3); } { $$ = make_reference_declarator ($2.t, $3); }
| '*' notype_declarator %prec UNARY | '*' notype_declarator %prec UNARY
{ $$ = make_pointer_declarator (NULL_TREE, $2); } { $$ = make_pointer_declarator (NULL_TREE, $2); }
| '&' notype_declarator %prec UNARY | '&' notype_declarator %prec UNARY
{ $$ = make_reference_declarator (NULL_TREE, $2); } { $$ = make_reference_declarator (NULL_TREE, $2); }
| ptr_to_mem type_quals notype_declarator | ptr_to_mem cv_qualifiers notype_declarator
{ tree arg = make_pointer_declarator ($2, $3); { tree arg = make_pointer_declarator ($2, $3);
$$ = build_parse_node (SCOPE_REF, $1, arg); $$ = build_parse_node (SCOPE_REF, $1, arg);
} }
...@@ -2978,15 +2953,15 @@ notype_declarator: ...@@ -2978,15 +2953,15 @@ notype_declarator:
; ;
complex_notype_declarator: complex_notype_declarator:
'*' nonempty_type_quals notype_declarator %prec UNARY '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
{ $$ = make_pointer_declarator ($2.t, $3); } { $$ = make_pointer_declarator ($2.t, $3); }
| '&' nonempty_type_quals notype_declarator %prec UNARY | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
{ $$ = make_reference_declarator ($2.t, $3); } { $$ = make_reference_declarator ($2.t, $3); }
| '*' complex_notype_declarator %prec UNARY | '*' complex_notype_declarator %prec UNARY
{ $$ = make_pointer_declarator (NULL_TREE, $2); } { $$ = make_pointer_declarator (NULL_TREE, $2); }
| '&' complex_notype_declarator %prec UNARY | '&' complex_notype_declarator %prec UNARY
{ $$ = make_reference_declarator (NULL_TREE, $2); } { $$ = make_reference_declarator (NULL_TREE, $2); }
| ptr_to_mem type_quals notype_declarator | ptr_to_mem cv_qualifiers notype_declarator
{ tree arg = make_pointer_declarator ($2, $3); { tree arg = make_pointer_declarator ($2, $3);
$$ = build_parse_node (SCOPE_REF, $1, arg); $$ = build_parse_node (SCOPE_REF, $1, arg);
} }
...@@ -2994,8 +2969,8 @@ complex_notype_declarator: ...@@ -2994,8 +2969,8 @@ complex_notype_declarator:
; ;
complex_direct_notype_declarator: complex_direct_notype_declarator:
direct_notype_declarator maybe_parmlist type_quals %prec '.' direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
{ $$ = build_parse_node (CALL_EXPR, $$, $2, $3); } { $$ = make_call_declarator ($$, $2, $3, $4); }
| '(' complex_notype_declarator ')' | '(' complex_notype_declarator ')'
{ $$ = $2; } { $$ = $2; }
| direct_notype_declarator '[' nonmomentary_expr ']' | direct_notype_declarator '[' nonmomentary_expr ']'
...@@ -3119,19 +3094,19 @@ global_scope: ...@@ -3119,19 +3094,19 @@ global_scope:
/* ANSI new-declarator (5.3.4) */ /* ANSI new-declarator (5.3.4) */
new_declarator: new_declarator:
'*' type_quals new_declarator '*' cv_qualifiers new_declarator
{ $$ = make_pointer_declarator ($2, $3); } { $$ = make_pointer_declarator ($2, $3); }
| '*' type_quals %prec EMPTY | '*' cv_qualifiers %prec EMPTY
{ $$ = make_pointer_declarator ($2, NULL_TREE); } { $$ = make_pointer_declarator ($2, NULL_TREE); }
| '&' type_quals new_declarator %prec EMPTY | '&' cv_qualifiers new_declarator %prec EMPTY
{ $$ = make_reference_declarator ($2, $3); } { $$ = make_reference_declarator ($2, $3); }
| '&' type_quals %prec EMPTY | '&' cv_qualifiers %prec EMPTY
{ $$ = make_reference_declarator ($2, NULL_TREE); } { $$ = make_reference_declarator ($2, NULL_TREE); }
| ptr_to_mem type_quals %prec EMPTY | ptr_to_mem cv_qualifiers %prec EMPTY
{ tree arg = make_pointer_declarator ($2, NULL_TREE); { tree arg = make_pointer_declarator ($2, NULL_TREE);
$$ = build_parse_node (SCOPE_REF, $1, arg); $$ = build_parse_node (SCOPE_REF, $1, arg);
} }
| ptr_to_mem type_quals new_declarator | ptr_to_mem cv_qualifiers new_declarator
{ tree arg = make_pointer_declarator ($2, $3); { tree arg = make_pointer_declarator ($2, $3);
$$ = build_parse_node (SCOPE_REF, $1, arg); $$ = build_parse_node (SCOPE_REF, $1, arg);
} }
...@@ -3148,27 +3123,27 @@ direct_new_declarator: ...@@ -3148,27 +3123,27 @@ direct_new_declarator:
/* ANSI abstract-declarator (8.1) */ /* ANSI abstract-declarator (8.1) */
absdcl: absdcl:
'*' nonempty_type_quals absdcl '*' nonempty_cv_qualifiers absdcl
{ $$ = make_pointer_declarator ($2.t, $3); } { $$ = make_pointer_declarator ($2.t, $3); }
| '*' absdcl | '*' absdcl
{ $$ = make_pointer_declarator (NULL_TREE, $2); } { $$ = make_pointer_declarator (NULL_TREE, $2); }
| '*' nonempty_type_quals %prec EMPTY | '*' nonempty_cv_qualifiers %prec EMPTY
{ $$ = make_pointer_declarator ($2.t, NULL_TREE); } { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
| '*' %prec EMPTY | '*' %prec EMPTY
{ $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); } { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
| '&' nonempty_type_quals absdcl | '&' nonempty_cv_qualifiers absdcl
{ $$ = make_reference_declarator ($2.t, $3); } { $$ = make_reference_declarator ($2.t, $3); }
| '&' absdcl | '&' absdcl
{ $$ = make_reference_declarator (NULL_TREE, $2); } { $$ = make_reference_declarator (NULL_TREE, $2); }
| '&' nonempty_type_quals %prec EMPTY | '&' nonempty_cv_qualifiers %prec EMPTY
{ $$ = make_reference_declarator ($2.t, NULL_TREE); } { $$ = make_reference_declarator ($2.t, NULL_TREE); }
| '&' %prec EMPTY | '&' %prec EMPTY
{ $$ = make_reference_declarator (NULL_TREE, NULL_TREE); } { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
| ptr_to_mem type_quals %prec EMPTY | ptr_to_mem cv_qualifiers %prec EMPTY
{ tree arg = make_pointer_declarator ($2, NULL_TREE); { tree arg = make_pointer_declarator ($2, NULL_TREE);
$$ = build_parse_node (SCOPE_REF, $1, arg); $$ = build_parse_node (SCOPE_REF, $1, arg);
} }
| ptr_to_mem type_quals absdcl | ptr_to_mem cv_qualifiers absdcl
{ tree arg = make_pointer_declarator ($2, $3); { tree arg = make_pointer_declarator ($2, $3);
$$ = build_parse_node (SCOPE_REF, $1, arg); $$ = build_parse_node (SCOPE_REF, $1, arg);
} }
...@@ -3181,20 +3156,20 @@ direct_abstract_declarator: ...@@ -3181,20 +3156,20 @@ direct_abstract_declarator:
{ $$ = $2; } { $$ = $2; }
/* `(typedef)1' is `int'. */ /* `(typedef)1' is `int'. */
| PAREN_STAR_PAREN | PAREN_STAR_PAREN
| direct_abstract_declarator '(' parmlist ')' type_quals %prec '.' | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
{ $$ = build_parse_node (CALL_EXPR, $$, $3, $5); } { $$ = make_call_declarator ($$, $3, $5, $6); }
| direct_abstract_declarator LEFT_RIGHT type_quals %prec '.' | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
{ $$ = build_parse_node (CALL_EXPR, $$, empty_parms (), $3); } { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
| direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.' | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
{ $$ = build_parse_node (ARRAY_REF, $$, $3); } { $$ = build_parse_node (ARRAY_REF, $$, $3); }
| direct_abstract_declarator '[' ']' %prec '.' | direct_abstract_declarator '[' ']' %prec '.'
{ $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); } { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
| '(' complex_parmlist ')' type_quals %prec '.' | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
{ $$ = build_parse_node (CALL_EXPR, NULL_TREE, $2, $4); } { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
| regcast_or_absdcl type_quals %prec '.' | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
{ TREE_OPERAND ($$, 2) = $2; } { set_quals_and_spec ($$, $2, $3); }
| fcast_or_absdcl type_quals %prec '.' | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
{ TREE_OPERAND ($$, 2) = $2; } { set_quals_and_spec ($$, $2, $3); }
| '[' nonmomentary_expr ']' %prec '.' | '[' nonmomentary_expr ']' %prec '.'
{ $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); } { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
| '[' ']' %prec '.' | '[' ']' %prec '.'
...@@ -3212,18 +3187,21 @@ stmts: ...@@ -3212,18 +3187,21 @@ stmts:
| stmts errstmt | stmts errstmt
; ;
errstmt: error ';' errstmt:
error ';'
; ;
/* build the LET_STMT node before parsing its contents, /* build the LET_STMT node before parsing its contents,
so that any LET_STMTs within the context can have their display pointers so that any LET_STMTs within the context can have their display pointers
set up to point at this one. */ set up to point at this one. */
.pushlevel: /* empty */ .pushlevel:
/* empty */
{ do_pushlevel (); } { do_pushlevel (); }
; ;
.poplevel: /* empty */ .poplevel:
/* empty */
{ $$ = do_poplevel (); } { $$ = do_poplevel (); }
; ;
...@@ -3261,7 +3239,8 @@ compstmt_or_error: ...@@ -3261,7 +3239,8 @@ compstmt_or_error:
| error compstmt | error compstmt
; ;
compstmt: '{' compstmt:
'{'
{ {
if (current_template_parms) if (current_template_parms)
{ {
...@@ -3387,9 +3366,7 @@ simple_stmt: ...@@ -3387,9 +3366,7 @@ simple_stmt:
{ finish_stmt (); } { finish_stmt (); }
| simple_if %prec IF | simple_if %prec IF
{ if (! current_template_parms) expand_end_cond (); { if (! current_template_parms) expand_end_cond ();
expand_end_bindings (getdecls (), kept_level_p (), 1); do_poplevel ();
poplevel (kept_level_p (), 1, 0);
pop_momentary ();
finish_stmt (); } finish_stmt (); }
| WHILE | WHILE
{ {
...@@ -3560,9 +3537,7 @@ simple_stmt: ...@@ -3560,9 +3537,7 @@ simple_stmt:
pop_momentary (); pop_momentary ();
if (flag_new_for_scope > 0) if (flag_new_for_scope > 0)
{ {
expand_end_bindings (getdecls (), kept_level_p (), 1); do_poplevel ();
poplevel (kept_level_p (), 1, 0);
pop_momentary ();
} }
finish_stmt (); } finish_stmt (); }
| SWITCH .pushlevel '(' condition ')' | SWITCH .pushlevel '(' condition ')'
...@@ -3626,14 +3601,14 @@ simple_stmt: ...@@ -3626,14 +3601,14 @@ simple_stmt:
c_expand_return ($2); c_expand_return ($2);
finish_stmt (); finish_stmt ();
} }
| asm_keyword maybe_type_qual '(' string ')' ';' | asm_keyword maybe_cv_qualifier '(' string ')' ';'
{ if (TREE_CHAIN ($4)) $4 = combine_strings ($4); { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
emit_line_note (input_filename, lineno); emit_line_note (input_filename, lineno);
expand_asm ($4); expand_asm ($4);
finish_stmt (); finish_stmt ();
} }
/* This is the case with just output operands. */ /* This is the case with just output operands. */
| asm_keyword maybe_type_qual '(' string ':' asm_operands ')' ';' | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
{ if (TREE_CHAIN ($4)) $4 = combine_strings ($4); { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
emit_line_note (input_filename, lineno); emit_line_note (input_filename, lineno);
c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE, c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
...@@ -3642,7 +3617,7 @@ simple_stmt: ...@@ -3642,7 +3617,7 @@ simple_stmt:
finish_stmt (); finish_stmt ();
} }
/* This is the case with input operands as well. */ /* This is the case with input operands as well. */
| asm_keyword maybe_type_qual '(' string ':' asm_operands ':' asm_operands ')' ';' | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
{ if (TREE_CHAIN ($4)) $4 = combine_strings ($4); { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
emit_line_note (input_filename, lineno); emit_line_note (input_filename, lineno);
c_expand_asm_operands ($4, $6, $8, NULL_TREE, c_expand_asm_operands ($4, $6, $8, NULL_TREE,
...@@ -3651,7 +3626,7 @@ simple_stmt: ...@@ -3651,7 +3626,7 @@ simple_stmt:
finish_stmt (); finish_stmt ();
} }
/* This is the case with clobbered registers as well. */ /* This is the case with clobbered registers as well. */
| asm_keyword maybe_type_qual '(' string ':' asm_operands ':' | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
asm_operands ':' asm_clobbers ')' ';' asm_operands ':' asm_clobbers ')' ';'
{ if (TREE_CHAIN ($4)) $4 = combine_strings ($4); { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
emit_line_note (input_filename, lineno); emit_line_note (input_filename, lineno);
...@@ -3728,7 +3703,7 @@ handler_seq: ...@@ -3728,7 +3703,7 @@ handler_seq:
type_specifier_seq: type_specifier_seq:
typed_typespecs %prec EMPTY typed_typespecs %prec EMPTY
| nonempty_type_quals %prec EMPTY | nonempty_cv_qualifiers %prec EMPTY
; ;
handler_args: handler_args:
...@@ -3782,11 +3757,11 @@ for.init.statement: ...@@ -3782,11 +3757,11 @@ for.init.statement:
/* Either a type-qualifier or nothing. First thing in an `asm' statement. */ /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
maybe_type_qual: maybe_cv_qualifier:
/* empty */ /* empty */
{ emit_line_note (input_filename, lineno); { emit_line_note (input_filename, lineno);
$$ = NULL_TREE; } $$ = NULL_TREE; }
| TYPE_QUAL | CV_QUALIFIER
{ emit_line_note (input_filename, lineno); } { emit_line_note (input_filename, lineno); }
; ;
...@@ -3800,7 +3775,8 @@ xexpr: ...@@ -3800,7 +3775,8 @@ xexpr:
/* These are the operands other than the first string and colon /* These are the operands other than the first string and colon
in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */ in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
asm_operands: /* empty */ asm_operands:
/* empty */
{ $$ = NULL_TREE; } { $$ = NULL_TREE; }
| nonnull_asm_operands | nonnull_asm_operands
; ;
...@@ -3829,7 +3805,8 @@ asm_clobbers: ...@@ -3829,7 +3805,8 @@ asm_clobbers:
In C++, declaring a function with no parameters In C++, declaring a function with no parameters
means that that function takes *no* parameters. */ means that that function takes *no* parameters. */
parmlist: /* empty */ parmlist:
/* empty */
{ {
$$ = empty_parms(); $$ = empty_parms();
} }
...@@ -3928,28 +3905,8 @@ parms_comma: ...@@ -3928,28 +3905,8 @@ parms_comma:
; ;
/* A single parameter declaration or parameter type name, /* A single parameter declaration or parameter type name,
as found in a parmlist. The first four cases make up for 10% as found in a parmlist. */
of the time spent parsing C++. We cannot use them because
of `int id[]' which won't get parsed properly. */
named_parm: named_parm:
/*
typed_declspecs dont_see_typename '*' IDENTIFIER
{ tree specs = strip_attrs ($1.t);
$$.t = build_tree_list (specs, build_parse_node (INDIRECT_REF, $4));
$$.new_type_flag = $1.new_type_flag;
see_typename (); }
| typed_declspecs dont_see_typename '&' IDENTIFIER
{ tree specs = strip_attrs ($1.t);
$$.t = build_tree_list (specs, build_parse_node (ADDR_EXPR, $4));
$$.new_type_flag = $1.new_type_flag;
see_typename (); }
| TYPENAME IDENTIFIER
{ $$.t = build_tree_list (get_decl_list ($$), $2);
$$.new_type_flag = 0; }
| TYPESPEC IDENTIFIER
{ $$.t = build_tree_list (get_decl_list ($$), $2);
$$.new_type_flag = 0; }
| */
/* Here we expand typed_declspecs inline to avoid mis-parsing of /* Here we expand typed_declspecs inline to avoid mis-parsing of
TYPESPEC IDENTIFIER. */ TYPESPEC IDENTIFIER. */
typed_declspecs1 declarator typed_declspecs1 declarator
...@@ -3987,28 +3944,11 @@ parm: ...@@ -3987,28 +3944,11 @@ parm:
| type_id | type_id
; ;
see_typename: %prec EMPTY see_typename:
/* empty */ %prec EMPTY
{ see_typename (); } { see_typename (); }
; ;
/*
dont_see_typename: %prec EMPTY
{ dont_see_typename (); }
;
try_for_typename:
{
if ($<ttype>-1 == error_mark_node)
$$ = 0;
else
{
$$ = 1;
pushclass ($<ttype>-1, 1);
}
}
;
*/
bad_parm: bad_parm:
/* empty */ %prec EMPTY /* empty */ %prec EMPTY
{ {
...@@ -4026,7 +3966,7 @@ bad_parm: ...@@ -4026,7 +3966,7 @@ bad_parm:
; ;
exception_specification_opt: exception_specification_opt:
%prec EMPTY /* empty */ /* empty */ %prec EMPTY
{ $$ = NULL_TREE; } { $$ = NULL_TREE; }
| THROW '(' ansi_raise_identifiers ')' %prec EMPTY | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
{ $$ = $3; } { $$ = $3; }
...@@ -4051,17 +3991,18 @@ ansi_raise_identifiers: ...@@ -4051,17 +3991,18 @@ ansi_raise_identifiers:
conversion_declarator: conversion_declarator:
/* empty */ %prec EMPTY /* empty */ %prec EMPTY
{ $$ = NULL_TREE; } { $$ = NULL_TREE; }
| '*' type_quals conversion_declarator | '*' cv_qualifiers conversion_declarator
{ $$ = make_pointer_declarator ($2, $3); } { $$ = make_pointer_declarator ($2, $3); }
| '&' type_quals conversion_declarator | '&' cv_qualifiers conversion_declarator
{ $$ = make_reference_declarator ($2, $3); } { $$ = make_reference_declarator ($2, $3); }
| ptr_to_mem type_quals conversion_declarator | ptr_to_mem cv_qualifiers conversion_declarator
{ tree arg = make_pointer_declarator ($2, $3); { tree arg = make_pointer_declarator ($2, $3);
$$ = build_parse_node (SCOPE_REF, $1, arg); $$ = build_parse_node (SCOPE_REF, $1, arg);
} }
; ;
operator: OPERATOR operator:
OPERATOR
{ got_scope = NULL_TREE; } { got_scope = NULL_TREE; }
; ;
......
...@@ -118,7 +118,7 @@ process_template_parm (list, next) ...@@ -118,7 +118,7 @@ process_template_parm (list, next)
my_friendly_assert (TREE_CODE (TREE_PURPOSE (parm)) == TREE_LIST, 260); my_friendly_assert (TREE_CODE (TREE_PURPOSE (parm)) == TREE_LIST, 260);
/* is a const-param */ /* is a const-param */
parm = grokdeclarator (TREE_VALUE (parm), TREE_PURPOSE (parm), parm = grokdeclarator (TREE_VALUE (parm), TREE_PURPOSE (parm),
PARM, 0, NULL_TREE, NULL_TREE); PARM, 0, NULL_TREE);
/* A template parameter is not modifiable. */ /* A template parameter is not modifiable. */
TREE_READONLY (parm) = 1; TREE_READONLY (parm) = 1;
if (IS_AGGR_TYPE (TREE_TYPE (parm)) if (IS_AGGR_TYPE (TREE_TYPE (parm))
...@@ -1761,7 +1761,8 @@ tsubst (t, args, nargs, in_decl) ...@@ -1761,7 +1761,8 @@ tsubst (t, args, nargs, in_decl)
{ {
tree values = TYPE_ARG_TYPES (t); tree values = TYPE_ARG_TYPES (t);
tree context = TYPE_CONTEXT (t); tree context = TYPE_CONTEXT (t);
tree new_value; tree raises = TYPE_RAISES_EXCEPTIONS (t);
tree fntype;
/* Don't bother recursing if we know it won't change anything. */ /* Don't bother recursing if we know it won't change anything. */
if (values != void_list_node) if (values != void_list_node)
...@@ -1807,34 +1808,39 @@ tsubst (t, args, nargs, in_decl) ...@@ -1807,34 +1808,39 @@ tsubst (t, args, nargs, in_decl)
if (TREE_CODE (t) == FUNCTION_TYPE if (TREE_CODE (t) == FUNCTION_TYPE
&& context == NULL_TREE) && context == NULL_TREE)
{ {
new_value = build_function_type (type, values); fntype = build_function_type (type, values);
} }
else if (context == NULL_TREE) else if (context == NULL_TREE)
{ {
tree base = tsubst (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t))), tree base = tsubst (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t))),
args, nargs, in_decl); args, nargs, in_decl);
new_value = build_cplus_method_type (base, type, fntype = build_cplus_method_type (base, type,
TREE_CHAIN (values)); TREE_CHAIN (values));
} }
else else
{ {
new_value = make_node (TREE_CODE (t)); fntype = make_node (TREE_CODE (t));
TREE_TYPE (new_value) = type; TREE_TYPE (fntype) = type;
TYPE_CONTEXT (new_value) = context; TYPE_CONTEXT (fntype) = context;
TYPE_VALUES (new_value) = values; TYPE_VALUES (fntype) = values;
TYPE_SIZE (new_value) = TYPE_SIZE (t); TYPE_SIZE (fntype) = TYPE_SIZE (t);
TYPE_ALIGN (new_value) = TYPE_ALIGN (t); TYPE_ALIGN (fntype) = TYPE_ALIGN (t);
TYPE_MODE (new_value) = TYPE_MODE (t); TYPE_MODE (fntype) = TYPE_MODE (t);
if (TYPE_METHOD_BASETYPE (t)) if (TYPE_METHOD_BASETYPE (t))
TYPE_METHOD_BASETYPE (new_value) = tsubst (TYPE_METHOD_BASETYPE (t), TYPE_METHOD_BASETYPE (fntype) = tsubst (TYPE_METHOD_BASETYPE (t),
args, nargs, in_decl); args, nargs, in_decl);
/* Need to generate hash value. */ /* Need to generate hash value. */
my_friendly_abort (84); my_friendly_abort (84);
} }
new_value = build_type_variant (new_value, fntype = build_type_variant (fntype,
TYPE_READONLY (t), TYPE_READONLY (t),
TYPE_VOLATILE (t)); TYPE_VOLATILE (t));
return new_value; if (raises)
{
raises = tsubst (raises, args, nargs, in_decl);
fntype = build_exception_variant (fntype, raises);
}
return fntype;
} }
case ARRAY_TYPE: case ARRAY_TYPE:
{ {
...@@ -1880,9 +1886,11 @@ tsubst (t, args, nargs, in_decl) ...@@ -1880,9 +1886,11 @@ tsubst (t, args, nargs, in_decl)
tsubst_expr (TREE_OPERAND (t, 1), args, nargs, in_decl)); tsubst_expr (TREE_OPERAND (t, 1), args, nargs, in_decl));
case CALL_EXPR: case CALL_EXPR:
return build_parse_node return make_call_declarator
(CALL_EXPR, tsubst (TREE_OPERAND (t, 0), args, nargs, in_decl), (tsubst (TREE_OPERAND (t, 0), args, nargs, in_decl),
tsubst (TREE_OPERAND (t, 1), args, nargs, in_decl), NULL_TREE); tsubst (TREE_OPERAND (t, 1), args, nargs, in_decl),
TREE_OPERAND (t, 2),
tsubst (TREE_TYPE (t), args, nargs, in_decl));
case SCOPE_REF: case SCOPE_REF:
return build_parse_node return build_parse_node
...@@ -2182,9 +2190,8 @@ tsubst_expr (t, args, nargs, in_decl) ...@@ -2182,9 +2190,8 @@ tsubst_expr (t, args, nargs, in_decl)
dcl = start_decl dcl = start_decl
(tsubst (TREE_OPERAND (t, 0), args, nargs, in_decl), (tsubst (TREE_OPERAND (t, 0), args, nargs, in_decl),
tsubst (TREE_OPERAND (t, 1), args, nargs, in_decl), tsubst (TREE_OPERAND (t, 1), args, nargs, in_decl),
TREE_OPERAND (t, 3) != 0, TREE_OPERAND (t, 2) != 0);
tsubst (TREE_OPERAND (t, 2), args, nargs, in_decl)); init = tsubst_expr (TREE_OPERAND (t, 2), args, nargs, in_decl);
init = tsubst_expr (TREE_OPERAND (t, 3), args, nargs, in_decl);
cp_finish_decl cp_finish_decl
(dcl, init, NULL_TREE, 1, /*init ? LOOKUP_ONLYCONVERTING :*/ 0); (dcl, init, NULL_TREE, 1, /*init ? LOOKUP_ONLYCONVERTING :*/ 0);
resume_momentary (i); resume_momentary (i);
...@@ -3057,8 +3064,7 @@ void ...@@ -3057,8 +3064,7 @@ void
do_function_instantiation (declspecs, declarator, storage) do_function_instantiation (declspecs, declarator, storage)
tree declspecs, declarator, storage; tree declspecs, declarator, storage;
{ {
tree decl = grokdeclarator (declarator, declspecs, NORMAL, 0, tree decl = grokdeclarator (declarator, declspecs, NORMAL, 0, NULL_TREE);
NULL_TREE, NULL_TREE);
tree name; tree name;
tree fn; tree fn;
tree result = NULL_TREE; tree result = NULL_TREE;
...@@ -3354,7 +3360,7 @@ instantiate_decl (d) ...@@ -3354,7 +3360,7 @@ instantiate_decl (d)
lineno = DECL_SOURCE_LINE (d); lineno = DECL_SOURCE_LINE (d);
input_filename = DECL_SOURCE_FILE (d); input_filename = DECL_SOURCE_FILE (d);
start_function (NULL_TREE, d, NULL_TREE, NULL_TREE, 1); start_function (NULL_TREE, d, NULL_TREE, 1);
store_parm_decls (); store_parm_decls ();
if (t && TREE_CODE (t) == RETURN_INIT) if (t && TREE_CODE (t) == RETURN_INIT)
......
...@@ -25,6 +25,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -25,6 +25,7 @@ Boston, MA 02111-1307, USA. */
#include "cp-tree.h" #include "cp-tree.h"
#include "flags.h" #include "flags.h"
#include "output.h" #include "output.h"
#include "assert.h"
#undef NULL #undef NULL
#define NULL 0 #define NULL 0
...@@ -348,7 +349,7 @@ build_dynamic_cast (type, expr) ...@@ -348,7 +349,7 @@ build_dynamic_cast (type, expr)
{ {
enum tree_code tc = TREE_CODE (type); enum tree_code tc = TREE_CODE (type);
tree exprtype = TREE_TYPE (expr); tree exprtype = TREE_TYPE (expr);
enum tree_code ec = TREE_CODE (exprtype); enum tree_code ec;
tree dcast_fn; tree dcast_fn;
if (type == error_mark_node || expr == error_mark_node) if (type == error_mark_node || expr == error_mark_node)
...@@ -360,6 +361,9 @@ build_dynamic_cast (type, expr) ...@@ -360,6 +361,9 @@ build_dynamic_cast (type, expr)
return t; return t;
} }
assert (exprtype != NULL_TREE);
ec = TREE_CODE (exprtype);
switch (tc) switch (tc)
{ {
case POINTER_TYPE: case POINTER_TYPE:
...@@ -977,7 +981,7 @@ synthesize_tinfo_fn (fndecl) ...@@ -977,7 +981,7 @@ synthesize_tinfo_fn (fndecl)
DECL_ALIGN (tdecl) = TYPE_ALIGN (ptr_type_node); DECL_ALIGN (tdecl) = TYPE_ALIGN (ptr_type_node);
cp_finish_decl (tdecl, NULL_TREE, NULL_TREE, 0, 0); cp_finish_decl (tdecl, NULL_TREE, NULL_TREE, 0, 0);
start_function (NULL_TREE, fndecl, NULL_TREE, NULL_TREE, 1); start_function (NULL_TREE, fndecl, NULL_TREE, 1);
store_parm_decls (); store_parm_decls ();
clear_last_expr (); clear_last_expr ();
push_momentary (); push_momentary ();
......
...@@ -919,17 +919,19 @@ save_this (instance) ...@@ -919,17 +919,19 @@ save_this (instance)
/* Build a signature member function call. Looks up the signature table /* Build a signature member function call. Looks up the signature table
entry corresponding to FUNCTION. Depending on the value of the CODE entry corresponding to FUNCTION. Depending on the value of the CODE
field, either call the function in PFN directly, or use OFFSET to field, either call the function in PFN directly, or use OFFSET to
index INSTANCE's virtual function table. */ index the object's virtual function table. */
tree tree
build_signature_method_call (basetype, instance, function, parms) build_signature_method_call (function, parms)
tree basetype, instance, function, parms; tree function, parms;
{ {
tree instance = TREE_VALUE (parms);
tree saved_instance = save_this (instance); /* Create temp for `this'. */ tree saved_instance = save_this (instance); /* Create temp for `this'. */
tree object_ptr = build_optr_ref (saved_instance); tree object_ptr = build_optr_ref (saved_instance);
tree new_object_ptr, new_parms; tree new_object_ptr, new_parms;
tree signature_tbl_ptr = build_sptr_ref (saved_instance); tree signature_tbl_ptr = build_sptr_ref (saved_instance);
tree sig_field_name = DECL_NAME (DECL_MEMFUNC_POINTER_TO (function)); tree sig_field_name = DECL_NAME (DECL_MEMFUNC_POINTER_TO (function));
tree basetype = DECL_CONTEXT (function);
tree basetype_path = TYPE_BINFO (basetype); tree basetype_path = TYPE_BINFO (basetype);
tree tbl_entry = build_component_ref (build1 (INDIRECT_REF, basetype, tree tbl_entry = build_component_ref (build1 (INDIRECT_REF, basetype,
signature_tbl_ptr), signature_tbl_ptr),
......
...@@ -215,6 +215,9 @@ build_cplus_new (type, init) ...@@ -215,6 +215,9 @@ build_cplus_new (type, init)
tree slot; tree slot;
tree rval; tree rval;
if (TREE_CODE (init) == TARGET_EXPR || init == error_mark_node)
return init;
slot = build (VAR_DECL, type); slot = build (VAR_DECL, type);
layout_decl (slot, 0); layout_decl (slot, 0);
rval = build (NEW_EXPR, type, rval = build (NEW_EXPR, type,
......
...@@ -1966,9 +1966,14 @@ build_indirect_ref (ptr, errorstring) ...@@ -1966,9 +1966,14 @@ build_indirect_ref (ptr, errorstring)
tree ptr; tree ptr;
char *errorstring; char *errorstring;
{ {
register tree pointer = (TREE_CODE (TREE_TYPE (ptr)) == REFERENCE_TYPE ? register tree pointer, type;
ptr : default_conversion (ptr));
register tree type = TREE_TYPE (pointer); if (ptr == error_mark_node)
return error_mark_node;
pointer = (TREE_CODE (TREE_TYPE (ptr)) == REFERENCE_TYPE
? ptr : default_conversion (ptr));
type = TREE_TYPE (pointer);
if (ptr == current_class_ptr) if (ptr == current_class_ptr)
return current_class_ref; return current_class_ref;
...@@ -5054,20 +5059,106 @@ tree ...@@ -5054,20 +5059,106 @@ tree
build_static_cast (type, expr) build_static_cast (type, expr)
tree type, expr; tree type, expr;
{ {
tree intype, binfo;
int ok;
if (type == error_mark_node || expr == error_mark_node)
return error_mark_node;
if (TREE_CODE (expr) == OFFSET_REF)
expr = resolve_offset_ref (expr);
if (current_template_parms) if (current_template_parms)
{ {
tree t = build_min (STATIC_CAST_EXPR, type, expr); tree t = build_min (STATIC_CAST_EXPR, type, expr);
return t; return t;
} }
/* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
Strip such NOP_EXPRs if VALUE is being used in non-lvalue context. */
if (TREE_CODE (type) != REFERENCE_TYPE
&& TREE_CODE (expr) == NOP_EXPR
&& TREE_TYPE (expr) == TREE_TYPE (TREE_OPERAND (expr, 0)))
expr = TREE_OPERAND (expr, 0);
if (TREE_CODE (type) == VOID_TYPE)
return build1 (CONVERT_EXPR, type, expr);
if (type_unknown_p (expr))
{
expr = instantiate_type (type, expr, 1);
if (expr == error_mark_node)
return error_mark_node;
}
if (TREE_CODE (type) == REFERENCE_TYPE)
return (convert_from_reference
(convert_to_reference (type, expr, CONV_STATIC|CONV_IMPLICIT,
LOOKUP_COMPLAIN, NULL_TREE)));
if (IS_AGGR_TYPE (type))
return build_cplus_new
(type, (build_method_call
(NULL_TREE, ctor_identifier, build_tree_list (NULL_TREE, expr),
TYPE_BINFO (type), LOOKUP_NORMAL)));
expr = decay_conversion (expr);
intype = TREE_TYPE (expr);
/* FIXME handle casting to array type. */
ok = 0;
if (can_convert_arg (type, intype, expr))
ok = 1;
else if (TYPE_PTROB_P (type) && TYPE_PTROB_P (intype))
{
tree binfo;
if (IS_AGGR_TYPE (TREE_TYPE (type)) && IS_AGGR_TYPE (TREE_TYPE (intype))
&& (TYPE_READONLY (TREE_TYPE (type))
>= TYPE_READONLY (TREE_TYPE (intype)))
&& (TYPE_VOLATILE (TREE_TYPE (type))
>= TYPE_VOLATILE (TREE_TYPE (intype)))
&& (binfo = get_binfo (TREE_TYPE (intype), TREE_TYPE (type), 0))
&& ! TREE_VIA_VIRTUAL (binfo))
ok = 1;
}
else if (TYPE_PTRMEM_P (type) && TYPE_PTRMEM_P (intype))
{
if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type))),
TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (intype))), 1)
&& (TYPE_READONLY (TREE_TYPE (TREE_TYPE (type)))
>= TYPE_READONLY (TREE_TYPE (TREE_TYPE (intype))))
&& (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (type)))
>= TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (intype))))
&& (binfo = get_binfo (TYPE_OFFSET_BASETYPE (intype),
TYPE_OFFSET_BASETYPE (type), 0))
&& ! TREE_VIA_VIRTUAL (binfo))
ok = 1;
}
else if (TREE_CODE (intype) != BOOLEAN_TYPE
&& TREE_CODE (type) != ARRAY_TYPE
&& TREE_CODE (type) != FUNCTION_TYPE
&& can_convert (intype, type))
ok = 1;
if (ok)
return build_c_cast (type, expr, 0); return build_c_cast (type, expr, 0);
cp_error ("static_cast from `%T' to `%T'", intype, type);
return error_mark_node;
} }
tree tree
build_reinterpret_cast (type, expr) build_reinterpret_cast (type, expr)
tree type, expr; tree type, expr;
{ {
tree intype = TREE_TYPE (expr); tree intype;
if (type == error_mark_node || expr == error_mark_node)
return error_mark_node;
if (TREE_CODE (expr) == OFFSET_REF)
expr = resolve_offset_ref (expr);
if (current_template_parms) if (current_template_parms)
{ {
...@@ -5075,118 +5166,140 @@ build_reinterpret_cast (type, expr) ...@@ -5075,118 +5166,140 @@ build_reinterpret_cast (type, expr)
return t; return t;
} }
if (TYPE_PTRMEMFUNC_P (type)) if (TREE_CODE (type) != REFERENCE_TYPE)
if (TYPE_PTRMEMFUNC_P (intype)) {
return build1 (NOP_EXPR, type, expr); expr = decay_conversion (expr);
if (TYPE_PTRMEMFUNC_P (type))
type = TYPE_PTRMEMFUNC_FN_TYPE (type);
if (TYPE_PTRMEMFUNC_P (intype)) /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
intype = TYPE_PTRMEMFUNC_FN_TYPE (intype); Strip such NOP_EXPRs if VALUE is being used in non-lvalue context. */
if (TREE_CODE (expr) == NOP_EXPR
&& TREE_TYPE (expr) == TREE_TYPE (TREE_OPERAND (expr, 0)))
expr = TREE_OPERAND (expr, 0);
}
if (! POINTER_TYPE_P (type) && ! TREE_CODE (type) == INTEGER_TYPE) if (type_unknown_p (expr))
{ {
cp_error ("reinterpret_cast cannot convert to type `%T'", type); expr = instantiate_type (type, expr, 1);
if (expr == error_mark_node)
return error_mark_node; return error_mark_node;
} }
if (! POINTER_TYPE_P (intype) && ! TREE_CODE (intype) == INTEGER_TYPE)
intype = TREE_TYPE (expr);
if (TREE_CODE (type) == REFERENCE_TYPE)
{
if (! real_lvalue_p (expr))
{ {
cp_error ("reinterpret_cast cannot convert from type `%T'", type); cp_error ("reinterpret_cast from `%T' rvalue to `%T'", intype, type);
return error_mark_node; return error_mark_node;
} }
if (TREE_CODE (type) == INTEGER_TYPE && TREE_CODE (intype) != POINTER_TYPE) expr = build_unary_op (ADDR_EXPR, expr, 0);
if (expr != error_mark_node)
expr = build_reinterpret_cast
(build_pointer_type (TREE_TYPE (type)), expr);
if (expr != error_mark_node)
expr = build_indirect_ref (expr, 0);
return expr;
}
else if (comptypes (TYPE_MAIN_VARIANT (intype), TYPE_MAIN_VARIANT (type), 1))
return build_static_cast (type, expr);
if (TYPE_PTR_P (type) && (TREE_CODE (intype) == INTEGER_TYPE
|| TREE_CODE (intype) == ENUMERAL_TYPE))
/* OK */;
else if (TREE_CODE (type) == INTEGER_TYPE && TYPE_PTR_P (intype))
{ {
cp_error ("reinterpret_cast cannot convert non-pointer type `%T' to `%T'", if (TYPE_PRECISION (type) < TYPE_PRECISION (intype))
cp_pedwarn ("reinterpret_cast from `%T' to `%T' loses precision",
intype, type); intype, type);
return error_mark_node;
} }
if (TREE_CODE (intype) == INTEGER_TYPE && TREE_CODE (type) != POINTER_TYPE) else if ((TYPE_PTRFN_P (type) && TYPE_PTRFN_P (intype))
|| (TYPE_PTRMEMFUNC_P (type) && TYPE_PTRMEMFUNC_P (intype)))
{
if (TREE_READONLY_DECL_P (expr))
expr = decl_constant_value (expr);
return fold (build1 (NOP_EXPR, type, expr));
}
else if ((TYPE_PTRMEM_P (type) && TYPE_PTRMEM_P (intype))
|| (TYPE_PTROBV_P (type) && TYPE_PTROBV_P (intype)))
{ {
cp_error ("reinterpret_cast cannot convert `%T' to non-pointer type `%T'", if (! comp_ptr_ttypes_reinterpret (TREE_TYPE (type), TREE_TYPE (intype)))
cp_pedwarn ("reinterpret_cast from `%T' to `%T' casts away const (or volatile)",
intype, type); intype, type);
if (TREE_READONLY_DECL_P (expr))
expr = decl_constant_value (expr);
return fold (build1 (NOP_EXPR, type, expr));
}
else
{
cp_error ("reinterpret_cast from `%T' to `%T'", intype, type);
return error_mark_node; return error_mark_node;
} }
if (TREE_CODE (type) == POINTER_TYPE && TREE_CODE (intype) == POINTER_TYPE) return convert (type, expr);
expr = convert (ptr_type_node, expr);
return build_c_cast (type, expr, 0);
} }
tree tree
build_const_cast (type, expr) build_const_cast (type, expr)
tree type, expr; tree type, expr;
{ {
tree intype = TREE_TYPE (expr); tree intype;
tree t1, t2;
if (type == error_mark_node || expr == error_mark_node) if (type == error_mark_node || expr == error_mark_node)
return error_mark_node; return error_mark_node;
if (TREE_CODE (expr) == OFFSET_REF)
expr = resolve_offset_ref (expr);
if (current_template_parms) if (current_template_parms)
{ {
tree t = build_min (CONST_CAST_EXPR, type, expr); tree t = build_min (CONST_CAST_EXPR, type, expr);
return t; return t;
} }
if (TYPE_PTRMEMFUNC_P (type)) if (TREE_CODE (type) != REFERENCE_TYPE)
type = TYPE_PTRMEMFUNC_FN_TYPE (type);
if (TYPE_PTRMEMFUNC_P (intype))
intype = TYPE_PTRMEMFUNC_FN_TYPE (intype);
if (! POINTER_TYPE_P (type))
{
cp_error ("const_cast cannot convert to non-pointer type `%T'", type);
return error_mark_node;
}
if (TREE_CODE (type) == REFERENCE_TYPE && ! real_lvalue_p (expr))
{ {
cp_error ("const_cast cannot convert rvalue to type `%T'", type); expr = decay_conversion (expr);
return error_mark_node;
} /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
if (TREE_CODE (type) == POINTER_TYPE && TREE_CODE (intype) != POINTER_TYPE) Strip such NOP_EXPRs if VALUE is being used in non-lvalue context. */
{ if (TREE_CODE (expr) == NOP_EXPR
cp_error ("const_cast cannot convert non-pointer type `%T' to type `%T'", && TREE_TYPE (expr) == TREE_TYPE (TREE_OPERAND (expr, 0)))
intype, type); expr = TREE_OPERAND (expr, 0);
return error_mark_node;
} }
if (TREE_CODE (type) == REFERENCE_TYPE) if (type_unknown_p (expr))
{ {
t1 = TREE_TYPE (type); expr = instantiate_type (type, expr, 1);
t2 = intype; if (expr == error_mark_node)
return error_mark_node;
} }
else
{
t1 = TREE_TYPE (type);
t2 = TREE_TYPE (intype);
for (; TREE_CODE (t1) == POINTER_TYPE && TREE_CODE (t2) == POINTER_TYPE; intype = TREE_TYPE (expr);
t1 = TREE_TYPE (t1), t2 = TREE_TYPE (t2))
;
}
if (TREE_CODE (t1) == OFFSET_TYPE && TREE_CODE (t2) == OFFSET_TYPE) if (comptypes (TYPE_MAIN_VARIANT (intype), TYPE_MAIN_VARIANT (type), 1))
return build_static_cast (type, expr);
else if (TREE_CODE (type) == REFERENCE_TYPE)
{ {
if (TYPE_OFFSET_BASETYPE (t1) != TYPE_OFFSET_BASETYPE (t2)) if (! real_lvalue_p (expr))
{ {
cp_error ("const_cast cannot convert between pointers to members of different types `%T' and `%T'", cp_error ("const_cast from `%T' rvalue to `%T'", intype, type);
TYPE_OFFSET_BASETYPE (t2), TYPE_OFFSET_BASETYPE (t1));
return error_mark_node; return error_mark_node;
} }
t1 = TREE_TYPE (t1);
t2 = TREE_TYPE (t2);
}
if (TYPE_MAIN_VARIANT (t1) != TYPE_MAIN_VARIANT (t2)) if (comp_ptr_ttypes_const (TREE_TYPE (type), intype))
{ return (convert_from_reference
cp_error ("const_cast cannot convert unrelated type `%T' to `%T'", (convert_to_reference (type, expr, CONV_CONST|CONV_IMPLICIT,
t2, t1); LOOKUP_COMPLAIN, NULL_TREE)));
return error_mark_node;
} }
else if (TREE_CODE (type) == POINTER_TYPE
&& TREE_CODE (intype) == POINTER_TYPE
&& comp_ptr_ttypes_const (TREE_TYPE (type), TREE_TYPE (intype)))
return convert (type, expr);
return build_c_cast (type, expr, 0); cp_error ("const_cast from `%T' to `%T'", intype, type);
return error_mark_node;
} }
/* Build an expression representing a cast to type TYPE of expression EXPR. /* Build an expression representing a cast to type TYPE of expression EXPR.
...@@ -5348,15 +5461,9 @@ build_c_cast (type, expr, allow_nonconverting) ...@@ -5348,15 +5461,9 @@ build_c_cast (type, expr, allow_nonconverting)
} }
/* Always produce some operator for an explicit cast, /* Always produce some operator for an explicit cast,
so we can tell (for -pedantic) that the cast is no lvalue. so we can tell (for -pedantic) that the cast is no lvalue. */
Also, pedantically, don't let (void *) (FOO *) 0 be a null if (TREE_CODE (type) != REFERENCE_TYPE && value == expr
pointer constant. */ && real_lvalue_p (value))
if (TREE_CODE (type) != REFERENCE_TYPE
&& (value == expr
|| (pedantic
&& TREE_CODE (value) == INTEGER_CST
&& TREE_CODE (expr) == INTEGER_CST
&& TREE_CODE (TREE_TYPE (expr)) != INTEGER_TYPE)))
value = non_lvalue (value); value = non_lvalue (value);
return value; return value;
...@@ -7261,7 +7368,8 @@ comp_ptr_ttypes_real (to, from, constp) ...@@ -7261,7 +7368,8 @@ comp_ptr_ttypes_real (to, from, constp)
return 0; return 0;
if (TREE_CODE (from) == OFFSET_TYPE if (TREE_CODE (from) == OFFSET_TYPE
&& TYPE_OFFSET_BASETYPE (from) == TYPE_OFFSET_BASETYPE (to)) && comptypes (TYPE_OFFSET_BASETYPE (from),
TYPE_OFFSET_BASETYPE (to), 1))
continue; continue;
/* Const and volatile mean something different for function types, /* Const and volatile mean something different for function types,
...@@ -7317,3 +7425,62 @@ ptr_reasonably_similar (to, from) ...@@ -7317,3 +7425,62 @@ ptr_reasonably_similar (to, from)
(TYPE_MAIN_VARIANT (to), TYPE_MAIN_VARIANT (from), -1); (TYPE_MAIN_VARIANT (to), TYPE_MAIN_VARIANT (from), -1);
} }
} }
/* Like comp_ptr_ttypes, for const_cast. */
int
comp_ptr_ttypes_const (to, from)
tree to, from;
{
for (; ; to = TREE_TYPE (to), from = TREE_TYPE (from))
{
if (TREE_CODE (to) != TREE_CODE (from))
return 0;
if (TREE_CODE (from) == OFFSET_TYPE
&& comptypes (TYPE_OFFSET_BASETYPE (from),
TYPE_OFFSET_BASETYPE (to), 1))
continue;
if (TREE_CODE (to) != POINTER_TYPE)
return comptypes (TYPE_MAIN_VARIANT (to), TYPE_MAIN_VARIANT (from), 1);
}
}
/* Like comp_ptr_ttypes, for reinterpret_cast. */
int
comp_ptr_ttypes_reinterpret (to, from)
tree to, from;
{
int constp = 1;
for (; ; to = TREE_TYPE (to), from = TREE_TYPE (from))
{
if (TREE_CODE (from) == OFFSET_TYPE)
from = TREE_TYPE (from);
if (TREE_CODE (to) == OFFSET_TYPE)
to = TREE_TYPE (to);
if (TREE_CODE (to) != TREE_CODE (from))
return 1;
/* Const and volatile mean something different for function types,
so the usual checks are not appropriate. */
if (TREE_CODE (to) != FUNCTION_TYPE && TREE_CODE (to) != METHOD_TYPE)
{
if (TYPE_READONLY (from) > TYPE_READONLY (to)
|| TYPE_VOLATILE (from) > TYPE_VOLATILE (to))
return 0;
if (! constp
&& (TYPE_READONLY (to) > TYPE_READONLY (from)
|| TYPE_VOLATILE (to) > TYPE_READONLY (from)))
return 0;
constp &= TYPE_READONLY (to);
}
if (TREE_CODE (to) != POINTER_TYPE)
return 1;
}
}
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