diff options
author | Jason Merrill <jason@redhat.com> | 2019-12-18 07:44:34 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2019-12-18 07:44:34 -0500 |
commit | 1ad431f95c200fe4d1eccab9cd5487087adc2bd8 (patch) | |
tree | a43658ed7be8f865ba478101168b95d555962029 /gcc/cp | |
parent | 542803c9adea448854477e0a544455cffda7cd51 (diff) | |
download | gcc-1ad431f95c200fe4d1eccab9cd5487087adc2bd8.zip gcc-1ad431f95c200fe4d1eccab9cd5487087adc2bd8.tar.gz gcc-1ad431f95c200fe4d1eccab9cd5487087adc2bd8.tar.bz2 |
PR c++/12333 - X::~X() with implicit this->.
this->X::~X() is handled by finish_class_member_access_expr and its
lookup_destructor subroutine; let's use it in cp_parser_lookup_name for the
case where this-> is implicit.
I tried replacing the other destructor code here with just the call to
lookup_destructor, but that regressed handling of naming the destructor
outside a non-static member function.
* parser.c (cp_parser_lookup_name): Use lookup_destructor.
* typeck.c (lookup_destructor): No longer static.
From-SVN: r279522
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/parser.c | 5 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 3 |
4 files changed, 13 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index eefe5bf..8b1d4e0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +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 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index b47698e..c35ed9a 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -7500,6 +7500,7 @@ extern tree build_class_member_access_expr (cp_expr, tree, tree, bool, 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); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index f610899..de79283 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -27939,6 +27939,11 @@ cp_parser_lookup_name (cp_parser *parser, tree name, 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); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index d381458..669ca83 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -59,7 +59,6 @@ static tree get_delta_difference (tree, tree, bool, bool, tsubst_flags_t); 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); @@ -2696,7 +2695,7 @@ build_class_member_access_expr (cp_expr object, tree member, /* 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) { |