+2019-12-17 Jason Merrill <jason@redhat.com>
+
+ PR c++/12333 - X::~X() with implicit this->.
+ * parser.c (cp_parser_lookup_name): Use lookup_destructor.
+ * typeck.c (lookup_destructor): No longer static.
+
2019-12-17 Martin Sebor <msebor@redhat.com>
PR c++/61339
tsubst_flags_t);
extern tree finish_class_member_access_expr (cp_expr, tree, bool,
tsubst_flags_t);
+extern tree lookup_destructor (tree, tree, tree, tsubst_flags_t);
extern tree build_x_indirect_ref (location_t, tree,
ref_operator,
tsubst_flags_t);
if (!type || !CLASS_TYPE_P (type))
return error_mark_node;
+ /* In a non-static member function, check implicit this->. */
+ if (current_class_ref)
+ return lookup_destructor (current_class_ref, parser->scope, name,
+ tf_warning_or_error);
+
if (CLASSTYPE_LAZY_DESTRUCTOR (type))
lazily_declare_fn (sfk_destructor, type);
static void casts_away_constness_r (tree *, tree *, tsubst_flags_t);
static bool casts_away_constness (tree, tree, tsubst_flags_t);
static bool maybe_warn_about_returning_address_of_local (tree);
-static tree lookup_destructor (tree, tree, tree, tsubst_flags_t);
static void error_args_num (location_t, tree, bool);
static int convert_arguments (tree, vec<tree, va_gc> **, tree, int,
tsubst_flags_t);
/* Return the destructor denoted by OBJECT.SCOPE::DTOR_NAME, or, if
SCOPE is NULL, by OBJECT.DTOR_NAME, where DTOR_NAME is ~type. */
-static tree
+tree
lookup_destructor (tree object, tree scope, tree dtor_name,
tsubst_flags_t complain)
{
--- /dev/null
+// PR c++/12333
+
+struct A { };
+
+struct X {
+ void f () {
+ X::~X ();
+ this->~X();
+ ~X(); // { dg-error "" "unary ~" }
+ A::~A (); // { dg-error "" }
+ X::~A (); // { dg-error "" }
+ }
+};
// destructor call.
struct Y {
- ~Y() {} // { dg-bogus "note" "implemented DR272" { xfail *-*-* } }
+ ~Y() {} // { dg-bogus "note" "implemented DR272" }
};
struct X : Y {
- ~X() {} // { dg-bogus "note" "implemented DR272" { xfail *-*-* } }
+ ~X() {} // { dg-bogus "note" "implemented DR272" }
void f() {
- X::~X(); // { dg-bogus "" "implemented DR272" { xfail *-*-* } }
- Y::~Y(); // { dg-bogus "" "implemented DR272" { xfail *-*-* } }
+ X::~X(); // { dg-bogus "" "implemented DR272" }
+ Y::~Y(); // { dg-bogus "" "implemented DR272" }
}
};