Commit 26877584 by Jason Merrill Committed by Jason Merrill

method.c (build_decl_overload_real): Fix namespace handling.

	* method.c (build_decl_overload_real): Fix namespace handling.
	* typeck.c (build_unary_op): Extract a lone function from an
	OVERLOAD.
	* call.c (build_scoped_method_call): Handle getting a namespace
	for basetype in a destructor call.
	(check_dtor_name): Handle enums.
	* parse.y (using_directive): New nonterminal.
	(extdef, simple_stmt): Use it.

From-SVN: r21174
parent 8508a96d
1998-07-15 Jason Merrill <jason@yorick.cygnus.com>
* method.c (build_decl_overload_real): Fix namespace handling.
* typeck.c (build_unary_op): Extract a lone function from an
OVERLOAD.
* call.c (build_scoped_method_call): Handle getting a namespace
for basetype in a destructor call.
(check_dtor_name): Handle enums.
* parse.y (using_directive): New nonterminal.
(extdef, simple_stmt): Use it.
1998-07-14 Martin von Lwis <loewis@informatik.hu-berlin.de> 1998-07-14 Martin von Lwis <loewis@informatik.hu-berlin.de>
* decl2.c (add_function): Move error message ... * decl2.c (add_function): Move error message ...
......
...@@ -356,7 +356,9 @@ check_dtor_name (basetype, name) ...@@ -356,7 +356,9 @@ check_dtor_name (basetype, name)
/* OK */; /* OK */;
else if (TREE_CODE (name) == IDENTIFIER_NODE) else if (TREE_CODE (name) == IDENTIFIER_NODE)
{ {
if (IS_AGGR_TYPE (basetype) && name == constructor_name (basetype)) if ((IS_AGGR_TYPE (basetype) && name == constructor_name (basetype))
|| (TREE_CODE (basetype) == ENUMERAL_TYPE
&& name == TYPE_IDENTIFIER (basetype)))
name = basetype; name = basetype;
else else
name = get_type_value (name); name = get_type_value (name);
...@@ -414,20 +416,29 @@ build_scoped_method_call (exp, basetype, name, parms) ...@@ -414,20 +416,29 @@ build_scoped_method_call (exp, basetype, name, parms)
binfo = NULL_TREE; binfo = NULL_TREE;
/* Check the destructor call syntax. */ /* Check the destructor call syntax. */
if (TREE_CODE (name) == BIT_NOT_EXPR && ! check_dtor_name (basetype, name)) if (TREE_CODE (name) == BIT_NOT_EXPR)
cp_error ("qualified type `%T' does not match destructor name `~%T'",
basetype, TREE_OPERAND (name, 0));
/* Destructors can be "called" for simple types; see 5.2.4 and 12.4 Note
that explicit ~int is caught in the parser; this deals with typedefs
and template parms. */
if (TREE_CODE (name) == BIT_NOT_EXPR && ! IS_AGGR_TYPE (basetype))
{ {
if (TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (basetype)) /* We can get here if someone writes their destructor call like
cp_error ("type of `%E' does not match destructor type `%T' (type was `%T')", `obj.NS::~T()'; this isn't really a scoped method call, so hand
exp, basetype, type); it off. */
if (TREE_CODE (basetype) == NAMESPACE_DECL)
return cp_convert (void_type_node, exp); return build_method_call (exp, name, parms, NULL_TREE, LOOKUP_NORMAL);
if (! check_dtor_name (basetype, name))
cp_error ("qualified type `%T' does not match destructor name `~%T'",
basetype, TREE_OPERAND (name, 0));
/* Destructors can be "called" for simple types; see 5.2.4 and 12.4 Note
that explicit ~int is caught in the parser; this deals with typedefs
and template parms. */
if (! IS_AGGR_TYPE (basetype))
{
if (TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (basetype))
cp_error ("type of `%E' does not match destructor type `%T' (type was `%T')",
exp, basetype, type);
return cp_convert (void_type_node, exp);
}
} }
if (! is_aggr_type (basetype, 1)) if (! is_aggr_type (basetype, 1))
......
...@@ -1539,7 +1539,8 @@ build_decl_overload_real (dname, parms, ret_type, tparms, targs, ...@@ -1539,7 +1539,8 @@ build_decl_overload_real (dname, parms, ret_type, tparms, targs,
as the declaration. Unfortunately, we don't have the _DECL, as the declaration. Unfortunately, we don't have the _DECL,
only its name */ only its name */
OB_PUTC ('F'); OB_PUTC ('F');
else if (!for_method)
if (!for_method && current_namespace != global_namespace)
/* qualify with namespace */ /* qualify with namespace */
build_qualified_name (current_namespace); build_qualified_name (current_namespace);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -405,7 +405,7 @@ extdef: ...@@ -405,7 +405,7 @@ extdef:
{ pop_namespace (); } { pop_namespace (); }
| NAMESPACE identifier '=' | NAMESPACE identifier '='
{ begin_only_namespace_names (); } { begin_only_namespace_names (); }
any_id ';' any_id ';'
{ {
end_only_namespace_names (); end_only_namespace_names ();
if (lastiddecl) if (lastiddecl)
...@@ -414,18 +414,7 @@ extdef: ...@@ -414,18 +414,7 @@ extdef:
} }
| using_decl ';' | using_decl ';'
{ do_toplevel_using_decl ($1); } { do_toplevel_using_decl ($1); }
| USING NAMESPACE | using_directive
{ begin_only_namespace_names (); }
any_id ';'
{
end_only_namespace_names ();
/* If no declaration was found, the using-directive is
invalid. Since that was not reported, we need the
identifier for the error message. */
if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
$4 = lastiddecl;
do_using_directive ($4);
}
| extension extdef | extension extdef
{ pedantic = $<itype>1; } { pedantic = $<itype>1; }
; ;
...@@ -448,6 +437,21 @@ namespace_using_decl: ...@@ -448,6 +437,21 @@ namespace_using_decl:
{ $$ = build_parse_node (SCOPE_REF, $3, $4); } { $$ = build_parse_node (SCOPE_REF, $3, $4); }
; ;
using_directive:
USING NAMESPACE
{ begin_only_namespace_names (); }
any_id ';'
{
end_only_namespace_names ();
/* If no declaration was found, the using-directive is
invalid. Since that was not reported, we need the
identifier for the error message. */
if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
$4 = lastiddecl;
do_using_directive ($4);
}
;
namespace_qualifier: namespace_qualifier:
NSNAME SCOPE NSNAME SCOPE
{ {
...@@ -3281,12 +3285,7 @@ simple_stmt: ...@@ -3281,12 +3285,7 @@ simple_stmt:
| ';' | ';'
{ finish_stmt (); } { finish_stmt (); }
| try_block | try_block
| USING NAMESPACE any_id ';' | using_directive
{
if (TREE_CODE ($3) == IDENTIFIER_NODE && lastiddecl)
$3 = lastiddecl;
do_using_directive ($3);
}
| namespace_using_decl | namespace_using_decl
{ do_local_using_decl ($1); } { do_local_using_decl ($1); }
; ;
......
...@@ -4547,6 +4547,14 @@ build_unary_op (code, xarg, noconvert) ...@@ -4547,6 +4547,14 @@ build_unary_op (code, xarg, noconvert)
return build1 (ADDR_EXPR, unknown_type_node, arg); return build1 (ADDR_EXPR, unknown_type_node, arg);
} }
/* If we have a single function from a using decl, pull it out. */
if (TREE_CODE (arg) == OVERLOAD
&& ! really_overloaded_fn (arg))
{
arg = OVL_FUNCTION (arg);
argtype = TREE_TYPE (arg);
}
if (TREE_CODE (arg) == OVERLOAD if (TREE_CODE (arg) == OVERLOAD
|| (TREE_CODE (arg) == OFFSET_REF || (TREE_CODE (arg) == OFFSET_REF
&& TREE_CODE (TREE_OPERAND (arg, 1)) == TEMPLATE_ID_EXPR)) && TREE_CODE (TREE_OPERAND (arg, 1)) == TEMPLATE_ID_EXPR))
......
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