diff options
author | Nathan Sidwell <nathan@acm.org> | 2019-05-01 11:38:54 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2019-05-01 11:38:54 +0000 |
commit | 9a54a0d916273cf9b1be93ee5b9bed207bd3ef40 (patch) | |
tree | 0f009dad0bed690608819485a85f9248299e16d9 /gcc | |
parent | 243dd48646beb0de2a2aac8236eef8fa60f5b99d (diff) | |
download | gcc-9a54a0d916273cf9b1be93ee5b9bed207bd3ef40.zip gcc-9a54a0d916273cf9b1be93ee5b9bed207bd3ef40.tar.gz gcc-9a54a0d916273cf9b1be93ee5b9bed207bd3ef40.tar.bz2 |
[C++ PATCH] Simplify class member lookup
https://gcc.gnu.org/ml/gcc-patches/2019-05/msg00004.html
gcc/cp/
* name-lookup.h (get_class_binding_direct): Change final arg to
bool.
(get_class_binding): Likewise.
* name-lookup.c (get_class_binding_direct): Replace TYPE_OR_FNS
arg with WANT_TYPE bool. Simplify.
(get_class_binding): Adjust final arg.
* decl.c (reshape_init_class): Adjust get_class_binding calls.
gcc/testsuite/
* g++.dg/cpp0x/decltype9.C: Adjust expected diagnostics.
From-SVN: r270765
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/decl.c | 4 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 35 | ||||
-rw-r--r-- | gcc/cp/name-lookup.h | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/decltype9.C | 3 |
6 files changed, 34 insertions, 26 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ec15854..3213b4a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2019-05-01 Nathan Sidwell <nathan@acm.org> + + * name-lookup.h (get_class_binding_direct): Change final arg to + bool. + (get_class_binding): Likewise. + * name-lookup.c (get_class_binding_direct): Replace TYPE_OR_FNS + arg with WANT_TYPE bool. Simplify. + (get_class_binding): Adjust final arg. + * decl.c (reshape_init_class): Adjust get_class_binding calls. + 2019-04-30 Nathan Sidwell <nathan@acm.org> * cp-objcp-common.c (cp_common_init_ts): Use MARK_TS_EXP for _EXPR diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5c4a38e..ee38ac2 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5968,12 +5968,12 @@ reshape_init_class (tree type, reshape_iter *d, bool first_initializer_p, tree id = DECL_NAME (d->cur->index); gcc_assert (id); gcc_checking_assert (d->cur->index - == get_class_binding (type, id, false)); + == get_class_binding (type, id)); field = d->cur->index; } } else if (TREE_CODE (d->cur->index) == IDENTIFIER_NODE) - field = get_class_binding (type, d->cur->index, false); + field = get_class_binding (type, d->cur->index); else { if (complain & tf_error) diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 4ca976c..89d85f6 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -1217,7 +1217,7 @@ search_anon_aggr (tree anon, tree name, bool want_type) Use this if you do not want lazy member creation. */ tree -get_class_binding_direct (tree klass, tree name, int type_or_fns) +get_class_binding_direct (tree klass, tree name, bool want_type) { gcc_checking_assert (RECORD_OR_UNION_TYPE_P (klass)); @@ -1233,31 +1233,26 @@ get_class_binding_direct (tree klass, tree name, int type_or_fns) val = member_vec_binary_search (member_vec, lookup); if (!val) ; - else if (type_or_fns > 0) - { - if (STAT_HACK_P (val)) - val = STAT_TYPE (val); - else if (!DECL_DECLARES_TYPE_P (val)) - val = NULL_TREE; - } else if (STAT_HACK_P (val)) - val = STAT_DECL (val); + val = want_type ? STAT_TYPE (val) : STAT_DECL (val); + else if (want_type && !DECL_DECLARES_TYPE_P (val)) + val = NULL_TREE; } else { - if (member_vec && type_or_fns <= 0) + if (member_vec && !want_type) val = member_vec_linear_search (member_vec, lookup); - if (type_or_fns < 0) - /* Don't bother looking for field. We don't want it. */; - else if (!val || (TREE_CODE (val) == OVERLOAD - && OVL_DEDUP_P (val))) + if (!val || (TREE_CODE (val) == OVERLOAD && OVL_DEDUP_P (val))) /* Dependent using declarations are a 'field', make sure we return that even if we saw an overload already. */ - if (tree field_val = fields_linear_search (klass, lookup, - type_or_fns > 0)) - if (!val || TREE_CODE (field_val) == USING_DECL) - val = field_val; + if (tree field_val = fields_linear_search (klass, lookup, want_type)) + { + if (!val) + val = field_val; + else if (TREE_CODE (field_val) == USING_DECL) + val = ovl_make (field_val, val); + } } /* Extract the conversion operators asked for, unless the general @@ -1278,7 +1273,7 @@ get_class_binding_direct (tree klass, tree name, int type_or_fns) special function creation as necessary. */ tree -get_class_binding (tree klass, tree name, int type_or_fns) +get_class_binding (tree klass, tree name, bool want_type) { klass = complete_type (klass); @@ -1308,7 +1303,7 @@ get_class_binding (tree klass, tree name, int type_or_fns) } } - return get_class_binding_direct (klass, name, type_or_fns); + return get_class_binding_direct (klass, name, want_type); } /* Find the slot containing overloads called 'NAME'. If there is no diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h index a47486d..311654a 100644 --- a/gcc/cp/name-lookup.h +++ b/gcc/cp/name-lookup.h @@ -303,8 +303,8 @@ extern void do_namespace_alias (tree, tree); extern tree do_class_using_decl (tree, tree); extern tree lookup_arg_dependent (tree, tree, vec<tree, va_gc> *); extern tree search_anon_aggr (tree, tree, bool = false); -extern tree get_class_binding_direct (tree, tree, int type_or_fns = -1); -extern tree get_class_binding (tree, tree, int type_or_fns = -1); +extern tree get_class_binding_direct (tree, tree, bool want_type = false); +extern tree get_class_binding (tree, tree, bool want_type = false); extern tree *find_member_slot (tree klass, tree name); extern tree *add_member_slot (tree klass, tree name); extern void resort_type_member_vec (void *, void *, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2d0240b..1427a8e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-05-01 Nathan Sidwell <nathan@acm.org> + + * g++.dg/cpp0x/decltype9.C: Adjust expected diagnostics. + 2019-04-30 Jakub Jelinek <jakub@redhat.com> PR target/89093 diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype9.C b/gcc/testsuite/g++.dg/cpp0x/decltype9.C index 45cd9ed..f6cfb0c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype9.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype9.C @@ -2,8 +2,7 @@ // { dg-do compile { target c++11 } } template<int> struct A { // { dg-message "defined here" } - static int i; + static int i; // { dg-message "candidate" } }; template<int N> int A<N>::i(decltype (A::i)); // { dg-error "no declaration" } -// { dg-message "no functions" "note" { target *-*-* } .-1 } |