* parser.c (cp_parser_unqualified_id): Check that destructor name
and scope match.
* call.c (check_dtor_name): Do not expect a BIT_NOT_EXPR.
Adjust comment. Return early if possible.
Use same_type_p to compare types.
* typeck.c (lookup_destructor): Adjust call to check_dtor_name.
* g++.dg/parse/dtor8.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@110168
138bc75d-0d04-0410-961f-
82ee72b054a4
+2006-01-24 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+
+ PR c++/25552
+ * parser.c (cp_parser_unqualified_id): Check that destructor name
+ and scope match.
+ * call.c (check_dtor_name): Do not expect a BIT_NOT_EXPR.
+ Adjust comment. Return early if possible.
+ Use same_type_p to compare types.
+ * typeck.c (lookup_destructor): Adjust call to check_dtor_name.
+
2006-01-24 Mark Mitchell <mark@codesourcery.com>
* semantics.c: Remove outdated comment.
static tree build_temp (tree, tree, int, diagnostic_fn_t *);
static void check_constructor_callable (tree, tree);
-/* Returns nonzero iff the destructor name specified in NAME
- (a BIT_NOT_EXPR) matches BASETYPE. The operand of NAME can take many
- forms... */
+/* Returns nonzero iff the destructor name specified in NAME matches BASETYPE.
+ NAME can take many forms... */
bool
check_dtor_name (tree basetype, tree name)
{
- name = TREE_OPERAND (name, 0);
-
/* Just accept something we've already complained about. */
if (name == error_mark_node)
return true;
if ((IS_AGGR_TYPE (basetype) && name == constructor_name (basetype))
|| (TREE_CODE (basetype) == ENUMERAL_TYPE
&& name == TYPE_IDENTIFIER (basetype)))
- name = basetype;
+ return true;
else
name = get_type_value (name);
}
return false;
}
- if (name && TYPE_MAIN_VARIANT (basetype) == TYPE_MAIN_VARIANT (name))
- return true;
- return false;
+ if (!name)
+ return false;
+ return same_type_p (TYPE_MAIN_VARIANT (basetype), TYPE_MAIN_VARIANT (name));
}
/* We want the address of a function or method. We avoid creating a
else if (type_decl == error_mark_node)
return error_mark_node;
+ /* Check that destructor name and scope match. */
+ if (declarator_p && scope && !check_dtor_name (scope, type_decl))
+ {
+ if (!cp_parser_uncommitted_to_tentative_parse_p (parser))
+ error ("declaration of %<~%T%> as member of %qT",
+ type_decl, scope);
+ return error_mark_node;
+ }
+
/* [class.dtor]
A typedef-name that names a class shall not be used as the
tree dtor_type = TREE_OPERAND (dtor_name, 0);
tree expr;
- if (scope && !check_dtor_name (scope, dtor_name))
+ if (scope && !check_dtor_name (scope, dtor_type))
{
error ("qualified type %qT does not match destructor name ~%qT",
scope, dtor_type);
+2006-01-24 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+
+ PR c++/25552
+ * g++.dg/parse/dtor8.C: New test.
+
2006-01-24 Hans-Peter Nilsson <hp@axis.com>
PR testsuite/25891
--- /dev/null
+// { dg-do compile }
+
+struct A {};
+
+struct B
+{
+ friend A::~B(); // { dg-error "as member of" }
+};